How to take a screen shot using HardwareButton (Power + VolumeDown) PROGRAMATICALLY

I want to capture GoogleMap screen shot

GoogleMap.Snapshot is another way to accomplish that but That is written in Java which I don't know how to convert.
https://stackoverflow.com/questions/13773658/capture-screen-shot-of-googlemap-android-api-v2/18093295#18093295

Answers

  • AsfendYarAsfendYar USMember ✭✭

    Yeah you can take the screen shot in xamarin forms quite easily.
    You don't even need a full Java or Swift code to make this possible in xamarin forms.
    All you need is just install the plugin i.e., Xam.Plugin.ScreenShot and this will do everything for you.
    Let me share a documentation link of this Nuget Package.
    https://github.com/wilsonvargas/ScreenshotPlugin

  • GolfMan2000GolfMan2000 Member ✭✭
    It's amazing when you do research on the search engines how much information comes up and of course that plug-in came up and I've already tried it before but it only captures the form not the map fragment content. There is quite a bit written about why that is... But most of those are talking heads that are ill informed.

    My Xamarin solution seemed to be stable and working well and it shows the map fragment and everything is functional about the maps. I used the form button event to trigger the plug-in capture. I save it to local storage and I can see the file and I can open up the jpeg only that is black. I'm not sure where I'm going wrong in plug-in implementation.
  • GolfMan2000GolfMan2000 Member ✭✭

    This is a second post on taking ScreenShot. The first one was posted because I tried what @SachinBali
    recommended without success. See my post

    https://forums.xamarin.com/discussion/comment/393297#Comment_393297

  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    Question:
    If you take a screenshot using the OS built-in screenshot feature... Home+Power or whatever it is your your device/OS... Is the map fragment still obfuscated? I never seem to have an issue taking screenshot that have Google Maps so I don't think they're doing anything fancy to protect their proprietary information: But could be.

  • GolfMan2000GolfMan2000 Member ✭✭
    edited October 25
    Hardware button creates a screenshot. Mapfragment and form content are captured.
  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭
    edited October 25

    @GolfMan2000 said:
    Hardware button creates a screenshot. Mapfragment and form content are captured.

    Terrific. So the component/fragment isn't blocking it in some way.
    Have you tried a basic app (not your full app) with a very simple page and the map fragment to see if that works - using the methods already suggested or that you've found through your research? If that works but your app doesn't, its another step closer.

    If that doesn't work either please post your capture code and maybe a link to a public repo others can download and look at to see if something jumps out.

  • GolfMan2000GolfMan2000 Member ✭✭
    I don't know how to do it using hardware buttons.

    In my other thread

    https://forums.xamarin.com/discussion/comment/393297#Comment_393297

    I posted a solution that is failing with capturing Mapfragment. If you want me to post code for that then please let's pickup on that thread... I want to keep these threads separated ... Thanks in advance.
  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    @GolfMan2000 said:
    I don't know how to do it using hardware buttons.

    I'm now lost. What is the actual problem:
    1 - That you need to know how to use that button combination to trigger the capture
    or
    2 - That your capture doesn't contain the map fragment

  • GolfMan2000GolfMan2000 Member ✭✭
    1) How to programmatically capture Google Map screenshot using hardware buttons. I have not been able to do this and it would be nice to know how to accomplish that. This post strictly focuses on this.

    And/Or

    2) How to programmatically capture Google Map screenshot using XamarinHelp or Xam.Plugin article which I have posted in the second thread.

    Hopefully this will clear the confusion.
  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    @GolfMan2000 said:
    1) How to programmatically capture Google Map screenshot using hardware buttons.

    I'll make another effort to explain why we, the readers, are confused.

    You're talking about two different things there and not telling us where you're lost.

    • Are you lost on how to do a screen capture - IN GENERAL. Because doing a capture is not specific to the button combinations. You could do that from any number of different trigger mechanisms.
    • Or are you lost on how to recognize the hardware buttons have been pressed so you can react to them? And that reaction could be any number of actions, ranging from a screen capture to sending a bug report.
      In other words you're talking about both the trigger and the response to the trigger and we don't know which half of this is a problem.

    Or is it "C: All the above"?
    Do you not know how to do either part of that?

  • GolfMan2000GolfMan2000 Member ✭✭
    I simply want to take a snapshot of the screen with Google Map by using either one of the two methods...thanks
  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    Clearly we're miscommunicating about what part of your question is where you're having problems.
    Maybe someone else here can find a different way to ask the question.

  • GolfMan2000GolfMan2000 Member ✭✭

    I am sorry that I Have caused you so much confusion.

    Lets try one more time try to focus on hardware buttons only. Lets say I have an app with GoogleMap Fragment. Lets say I am showing a pin at a location.

    Now if I wanted to capture The screen shot of the map and pin I simply hold down the Power button along with VolumeDown button simultaneously. This results in a screen capture that is save in the ScreenCapture Folder.

    Now supposing if I wanted to do exactly that using the code to simulate the pressing of those two buttons. What would that code would look like. Can you please share that code with the community.

    Hope this clarifies things.

Sign In or Register to comment.