Need to utilise the camera in my app for work, I see that things have changed in API >= 28 compared to how I used to do it where I could use startActivityForResult.
However I am facing a problem where I launch the camera app, and immediately get the 'TransactionTooLargeException' error message in the debug/run console.
For calling up the camera, I am doing
mGetContent = registerForActivityResult(
new ActivityResultContracts.TakePicture(),
result -> {
if (result) {
}
}
);
Where mGetContent is defined in the class as
private ActivityResultLauncher<Uri> mGetContent;
In my AndroidManifest.xml file I have the following
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="com.test.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="#xml/file_paths" />
</provider>
In my file_paths file I have
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<files-path
name="files"
path="."/>
<files-path
name="app_images"
path="./files/"/>
</paths>
I have a button set up in my activity where I launch the camera using
findViewById(R.id.button)).setOnClickListener(v -> {
File directory = new File(context.getFilesDir(), "app_images");
if (!directory.exists()) directory.mkdir();
File file = new File(directory, "image.jpg");
Uri uri = getUriForFile(this, "com.test.fileprovider", file);
mGetContent.launch(uri);
};
As soon as I tap on the button, and the camera app opens up, I get what I can only assume is an overly general error message.
E/JavaBinder: !!! FAILED BINDER TRANSACTION !!! (parcel size = 1284092)
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.test, PID: 14296
java.lang.RuntimeException: android.os.TransactionTooLargeException: data parcel size 1284092 bytes
at android.app.servertransaction.PendingTransactionActions$StopInfo.run(PendingTransactionActions.java:161)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7397)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:935)
Caused by: android.os.TransactionTooLargeException: data parcel size 1284092 bytes
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(BinderProxy.java:511)
at android.app.IActivityTaskManager$Stub$Proxy.activityStopped(IActivityTaskManager.java:4524)
at android.app.servertransaction.PendingTransactionActions$StopInfo.run(PendingTransactionActions.java:145)
Been trying to Google search to find things, but having trouble nailing down what the actual issue is.
Some suggestions pointed me towards the onSaveInstanceState, so I override that and set a breakpoint on it to see what was happening, but it made it through without any issues (from what I could tell).
Kind of at a loss with this one.
Wowsers as to what makes up the bundle in the onSaveInstanceState.
I have some imageviews, imagebuttons, and just general buttons in my app to make things easier for our staff.
I went through and changed the 'saveState' of all the ImageViews and ImageButtons from the default of true to false, since I don't care what state they were in, they are just visual guides.
Took the android:viewHierarchyState from 1.2MB down to 1.6KB, my Parcel size is now 3.3KB and it no longer crashes when suspending the app to bring up the camera app.
TooLargeTool was useful, but I couldn't make it work the way the Github page says, I told it to 'startLogging', and in my activity where the crash was happening, I set a breakpoint and checked if it was logging using 'isLogging' and it came back 'true'.
In the end I just had it log the output of TooLargeTool.bundleBreakdown(outState) in the onSaveInstanceState.
Thanks to Gabe Sechan and ianhanniballake for pointing me towards what it might be, there's not much out there on for this particular exception, I mean, there is, but it appears that it is different for everyone.
Really wish Google would print out a better set of error messages for it to make it easier to work out which activity was the problem (or in my case, all 3 activities combined).
Related
I am working in an app with maps using Here Maps but when the navigation launchs, the lane information doesn't show. I am following this example --> https://github.com/heremaps/here-android-sdk-examples/tree/master/advanced-navigation/app/src/main/java/com/here/android/example/advanced/navigation
I have tried debbug mode but it doesn't enter in LaneInfoUtils.java.
There is a error in the log, I don't know if it's related.
D/EgretLoader: EgretLoader(Context context)
The context is not activity
W/cr_AwContents: Application attempted to call on a destroyed WebView
java.lang.Throwable
at org.chromium.android_webview.AwContents.r(chromium-TrichromeWebViewGoogle.aab-stable-447212033:2)
at com.android.webview.chromium.WebViewChromium.addJavascriptInterface(chromium-TrichromeWebViewGoogle.aab-stable-447212033:6)
at android.webkit.WebView.addJavascriptInterface(WebView.java:1924)
at miui.contentcatcher.sdk.utils.WebViewUtils$NativeWebViewUtils.addJavascriptInterface(WebViewUtils.java:245)
at miui.contentcatcher.sdk.utils.WebViewUtils.initWebViewJsInterface(WebViewUtils.java:158)
at miui.contentcatcher.InterceptorProxy$1.run(InterceptorProxy.java:190)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:236)
at android.app.ActivityThread.main(ActivityThread.java:8060)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:656)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967)
W/ConnectivityManager.CallbackHandler: callback not found for CALLBACK_AVAILABLE message
W/ConnectivityManager.CallbackHandler: callback not found for CALLBACK_AVAILABLE message
Thank you :)
I was having issues with the Lane information as well. I ended up just going with the Realistic view, this shows a 2d image that shows you which lane you should take.
https://developer.here.com/documentation/android-premium/3.18/dev_guide/topics/map-guidance-events.html
Go to the link provided and scroll down to Realistic View. This will give you more information on how to implement it. I was able to get it working with the code provided in the docs, I didn't have to put the images on the app itself like I did with just the Lane Information.
I'm working with Android Studio, writing in Java. I'm trying to write a piece of software that will take pictures from a camera based on an event. So first steps first was to figure out the API. Camera is depreciated, so there's Camera2, but the latest is CameraX. I've attempted to use both CameraX and Camera2, but for some reason I'm not saving any images. I believe the capture works, but the issue is saving the files. I don't know what's going on.
First lets start with permissions. Yes, I have set permissions for both the camera and external storage.
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
So lets move on to the code itself.
I've never saved photos before, but I have worked with text files such as .txt and .csv files. Which I've been able to make work.
Right now I do a simple button click to capture the image. Which is nothing more than an onclicklistener. Once I press the button this is what actions occur.
SimpleDateFormat mDateFormat = new SimpleDateFormat("yyyyMMddHHmmss", Locale.US);
File file = new File(Environment.getDataDirectory(), mDateFormat.format(new Date())+ ".jpg");
if(!file.exists())
file.mkdirs();
ImageCapture.OutputFileOptions outputFileOptions = new ImageCapture.OutputFileOptions.Builder(file).build();
imageCapture.takePicture(outputFileOptions, executor, new ImageCapture.OnImageSavedCallback () {
#Override
public void onImageSaved(#NonNull ImageCapture.OutputFileResults outputFileResults) {
Toast.makeText(MainActivity.this, "TEST", Toast.LENGTH_SHORT).show();
new Handler().post(new Runnable() {
#Override
public void run() {
Toast.makeText(MainActivity.this, "Image Saved successfully", Toast.LENGTH_SHORT).show();
}
});
}
#Override
public void onError(#NonNull ImageCaptureException error) {
error.printStackTrace();
// Toast.makeText(MainActivity.this, "Image save FAILED!!!!", Toast.LENGTH_SHORT).show();
}
});
when the app launches the first time, it asks for permission and I grant permission. but looking at the run tab as part of the Android Studio ID, I get the following readout, when I press the capture button
D/ImageCapture: Send image capture request [current, pending] = [0, 1]
D/CaptureSession: Issuing capture request.
W/example.camera: JNI critical lock held for 21.148ms on Thread[14,tid=10076,Runnable,Thread*=0xdc743000,peer=0x13184cf8,"Binder:10045_2"]
W/ExifInterface: Stop reading file since a wrong offset may cause an infinite loop: 0
Skip the tag entry since data format (ULONG) is unexpected for tag: GPSAltitudeRef
W/ExifInterface: Stop reading file since a wrong offset may cause an infinite loop: 0
Stop reading file since a wrong offset may cause an infinite loop: 0
W/System.err: androidx.camera.core.ImageCaptureException: Failed to write or close the file
W/System.err: at androidx.camera.core.ImageCapture$3.onError(ImageCapture.java:669)
at androidx.camera.core.ImageSaver.lambda$postError$1$ImageSaver(ImageSaver.java:263)
at androidx.camera.core.-$$Lambda$ImageSaver$eAp-cZyzsEk-LVLazzLE-ezQzwo.run(Unknown Source:8)
W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:919)
Caused by: java.io.FileNotFoundException: /data/20200728142756.jpg: open failed: EACCES (Permission denied)
at libcore.io.IoBridge.open(IoBridge.java:496)
at java.io.FileOutputStream.<init>(FileOutputStream.java:235)
at java.io.FileOutputStream.<init>(FileOutputStream.java:186)
at androidx.camera.core.ImageSaver.run(ImageSaver.java:97)
... 3 more
W/System.err: Caused by: android.system.ErrnoException: open failed: EACCES (Permission denied)
at libcore.io.Linux.open(Native Method)
at libcore.io.ForwardingOs.open(ForwardingOs.java:167)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:252)
at libcore.io.ForwardingOs.open(ForwardingOs.java:167)
at android.app.ActivityThread$AndroidOs.open(ActivityThread.java:7255)
at libcore.io.IoBridge.open(IoBridge.java:482)
... 6 more
W/example.camera: JNI critical lock held for 17.651ms on Thread[16,tid=10083,Runnable,Thread*=0xdc74bc00,peer=0x13184de8,"Binder:10045_4"]
I've searched around, and looked for different methods of saving the file, and I've had success with saving the image, sort of, when I use the camera2 api and save the file using outputstream
When I use Camera2 it appears to save just fine, but I have no idea where it saves, I can't find it. I point this out, because it still appears to be a permission denied error as what I'm seeing is when I open up Device File Explorer its not letting me view /storage/emulator/ it just shows me
ls: /storage/emulated/: Permission denied.
all the examples I have found have assumed access with no issues to emulated.
Does anyone have any insight as to why I'm having permission denied errors?
UPDATE
So I still haven't solved the issue related to the failed mkdir() call. However, I did fix one issue, that could have been causing the issue. The means as to how I was creating the directory and the file itself wasn't correct.
SimpleDateFormat mDateFormat = new SimpleDateFormat("yyyyMMddHHmmss", Locale.US);
File file = new File(getBatchDirectoryName(), mDateFormat.format(new Date())+ ".jpg");
public String getBatchDirectoryName() {
String app_folder_path = "";
app_folder_path = Environment.getExternalStorageDirectory() + "/images";
File dir = new File(app_folder_path);
if (!dir.exists() && !dir.mkdirs()) {
Toast.makeText(MainActivity.this, "Trip", Toast.LENGTH_SHORT).show();
}
return app_folder_path;
}
However, it still fails to create the directory. Which still makes me come back to a permission issue.
Environment.getExternalStorageDirectory() appears to be deprecated. Documentation appears to recommend using getExternalFilesDir(string) or MediaStore. However, I'm having issues finding sample use cases. And I can't imagine, that while deprecated, it would just stop working at all. Most devices on the market are not API 29 or higher.
Based on help from #blackapps, I was able to make changes to my Manifest file to allow access to external storage.
More information can be found here
Request Legacy External Storage
With #blackapps, and this thread on stackoverflow I was able to update my permissions to allow legacy access.
Because in Android Q they have disabled direct file access, they have added a work around to allow legacy support. This is, and as others have mentioned, only a temporary fix for the issue. You will need to follow the new format for saving files going forward with Android R. In my situation, I am only developing a proof of concept and will not need to worry about future versions of Android.
To make the temporary fix, do the following
Add the following line
android:requestLegacyExternalStorage="true">
inside your <application bracket on the manifest file. Should look similar to this
<?xml version="1.0" encoding="utf-8"?>
...
package="com.example.camerax">
...
<application
...
android:requestLegacyExternalStorage="true">
<activity android:name=".MainActivity">
<intent-filter>
...
</intent-filter>
</activity>
</application>
remember this is not a long term fix, and will not work when a device is updated to Android R
I have a (big) problem on chromebook with a functionnality working fine on "classic" android devices (phones, tablets).
I try to send an e-mail with an attached file.
Here's a portion of code (api>=23).
Intent email = new Intent(Intent.ACTION_SEND);
String[] str = new String[1];
str[0] = "destination#yahoo.fr";
email.putExtra(Intent.EXTRA_EMAIL, str);
email.putExtra(Intent.EXTRA_TEXT, "My text");
email.putExtra(Intent.EXTRA_SUBJECT, "My subject");
Uri uri = FileProvider.getUriForFile(this, "com.TTT.fileprovider", new File(dest));
email.putExtra(android.content.Intent.EXTRA_STREAM, uri);
email.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION
| Intent.FLAG_GRANT_WRITE_URI_PERMISSION
| Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
email.setType("message/rfc822");
startActivity(email);
On my Phone (android 9 api 28), gmail app is called, all text fields are filled with correct information and the file (myResume.pdf) is correctly attached.
When sent then received, the e-mail contains a readable pdf file. that's cool.
With my chromebook (PB 314 / v. 83.0.4103.119), gmail is called, all text fields are filled with correct information but no attached file.
LogCat indicates :
2020-06-27 15:25:50.886 127-2348/? I/ActivityManager: START u0 {act=android.intent.action.SEND typ=message/rfc822 flg=0x43 cmp=org.chromium.arc.applauncher/.ChromeBrowserProxyActivity clip={message/rfc822 T:My text} (has extras)} from uid 10040
2020-06-27 15:25:50.887 565-565/? D/ArcDummy: New intent received: Intent { act=android.intent.action.SEND typ=message/rfc822 flg=0x10000043 cmp=org.chromium.arc.applauncher/.ChromeBrowserProxyActivity clip={message/rfc822 T:My text} (has extras) }
2020-06-27 15:25:50.887 565-565/? W/ContextImpl: Calling a method in the system process without a qualified user: android.app.ContextImpl.startService:1531 android.content.ContextWrapper.startService:664 org.chromium.arc.applauncher.DummyActivity.forwardIntentIfNeeded:155 org.chromium.arc.applauncher.DummyActivity.onNewIntent:121 android.app.Activity.performNewIntent:7255
2020-06-27 15:25:50.892 127-2348/? W/WindowManagerInjector: Attempted to get menu state of app token with non existing window
2020-06-27 15:25:50.896 780-842/? D/ArcMediaControllerManager: onTaskMovedToFront: 2
2020-06-27 15:25:50.897 780-842/? I/ArcMediaControllerManager: onAppBecameActive: org.chromium.arc.applauncher
2020-06-27 15:25:50.892 127-2348/? W/WindowManagerInjector: Attempted to get menu state of app token with non existing window
2020-06-27 15:25:50.900 127-760/? W/ActivityManager: For security reasons, the system cannot issue a Uri permission grant to content://com.TTT.fileprovider/images/myResume.pdf [user 0]; use startActivityAsCaller() instead
2020-06-27 15:25:50.901 127-760/? W/WindowManagerInjector: Attempted to get menu state of app token with non existing window
when testing on android phones, this sentence never appears :
For security reasons, the system cannot issue a Uri permission grant to content://com.TTT.fileprovider/images/myResume.pdf [user 0]; use startActivityAsCaller() instead
more information about previous code :
the file "myResume.pdf" is copied to a special directory for beeing shared with gmail.
dest is a string (/storage/emulated/0/MyDir/myResume.pdf) obtained with
Environment.getExternalStorageDirectory().toString() > /storage/emulated/0/
my sub directory, created and verified > MyDir/
the file > myResume.pdf
the file AndroidManifest.xml includes
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.TTT.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="#xml/provider_paths"/>
</provider>
the file #xml/provider_paths is :
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="images" path="myDir/"/>
</paths>
I hope I have explained my problem with all details,
Can anyone help me?
Thank you very much!
the problem is finally solved by using gmail app (after downloaded it) then using it instead of gmail/web/chrome.
I am trying to do WebRTC, all is working fine but there seems to be an issue, that is, if the screen remains off for more than a minute the audio stops recording, meaning the audio from device stops until I switch the screen on once again.
What I have tried?
1) I have tried setting webSettings.setMediaPlaybackRequiresUserGesture(false); it does no good to the problem.
2) I have also tried adding a wakelock in the activity in which I am doing WebRTC but it also didn't work.
Here are the permissions declared in Manifest:
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
Here in activity, I am granting permission for the microphone in WebChromeClient:
#Override
public void onPermissionRequest(final PermissionRequest request) {
request.grant(request.getResources());
}
What I want?
I want to be able to continue call without disrupting the user to turn screen back on again. Please point me in right direction.
Thanks!
Update: I tried loading the WebRTC url in Chrome and the same thing is happening, that is, audio stops recording from my device.
Update 2: Adding log when audio stops coming from the device.
2019-08-06 17:18:47.266 4332-22405/? V/APM_AudioPolicyManager: getAudioPolicyConfig: audioParam;outDevice
2019-08-06 17:18:47.266 4332-22405/? V/APM_AudioPolicyManager: getNewOutputDevice() selected device 2
2019-08-06 17:18:47.266 4332-22405/? V/APM_AudioPolicyManager: ### curdevice : 2
2019-08-06 17:18:47.307 4332-22405/? V/APM_AudioPolicyManager: AudioPolicyManager:setRecordSilenced(uid:99066, silenced:1)
2019-08-06 17:18:47.308 4332-22405/? V/APM_AudioPolicyManager: AudioPolicyManager:setRecordSilenced(uid:11556, silenced:1)
Update 3: Tried initializing WebView in a Foreground Service still same result.
Update 4: Tried a demo call on https://appr.tc/ using Chrome(76.0.3809.132). Observed the same result.
Update 5: Tried a demo call using Firefox and it worked FLAWLESSLY which lets me thinking that is it a Chromium bug?
Update 6: Filled a bug report
Android will automatically destroy your activity on a few minutes after leaving foreground that will cause the audio recording to turn off.
I have working with webrtc on android, if you want to create call and video call with webrtc on Android, I suggest to use native webrtc and implement everything related to webrtc on foreground service. Foreground service will ensure your recorder and camera to keep running event when activity is destroyed.
For reference, here the google sample for implementing webrtc native
https://webrtc.googlesource.com/src/+/master/examples/androidapp/src/org/appspot/apprtc
You should work on keeping the screen on in that activity during the call and prevent if from dimming.
Use this:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
and after your call is done:
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
Check your Chrome/Android version due to this issue with WebRTC on Android:
Issue 513633: WebRTC call in Chrome on Android will be cut off 1 min after screen off
WebRTC is supported by default in Chrome so... it should work.
BTW, if you dont't need WebRtc or want try to implement in a background service...
Interest readings:
1 - recording-when-screen-off
As the post says, keep in mind:
To call:
startForeground();
Use START_STICKY:
#Override
public int onStartCommand(Intent intent, int flags, int startId) {
return START_STICKY;
}
2 - how to implement a recorder
As the post says, keep in mind permissions:
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Background services with Apache Cordova
With cordova and a webview you need to use a plugin to run code in background as a service too.
Take a look at this link:
cordova plugin
Another choice with Cordova is to do your own plugin like this:
custom plugin - background video recorder
Obviously, it's no usual task, because all your implementation, it's just a WebView. Which very hard to align with such long living task and lifecycle inside Android. For ex. every VoIP application we did, had services in background, to keep connection alive, with wake locks. This was only one way to ensure about stability of the call.
However, I think you could try to do the same. By managing your WebView work inside Service. For this purpose, you could consider moving some calling logic into another view, and starting new Service and creation new Window. This will ensure your Window will be alive, during all the lifecycle of the Service.
Smth like.
public class ServiceWithWebView extends Service {
#Override
public void onCreate() {
super.onCreate();
final WindowManager windowManager = (WindowManager)
getSystemService(WINDOW_SERVICE);
params = new WindowManager.LayoutParams(WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY);
final LinearLayout view = new LinearLayout(this);
view.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout
.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT));
WebView wv = new WebView(this);
wv.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout
.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
view.addView(wv);
wv.loadUrl("http://google.com");
windowManager.addView(view, params);
}
}
It is possible that the problem is in battery optimization. The device cleans up the background processes and finds there your audio recording screen working on the background. try to add the app to the list of Battery Best Performance list. Search how to do that on your device.
For my case even important background tasks as accessibility service is forced to stop under that battery optimization algorithm. To allow my service to work all the time, the user should add the app to the whitelist of battery best performance rule.
I hope it can help you.
I'm trying to implement in my android app the Google Maps Places API.
When a button is clicked it opens the place picker, the picker works fine (you can move around, zoom in and out, search and go to current location), until when you try to click on the "Select this location" button; when the button is clicked a blank screen opens, and the only option is to close the app.
The same happens when the back button is pressed (either the one the navigation bar, or the one in the AppBar)
Image: Inside the Place Picker Activity
Image: Blank Screen
It was working fine a few weeks ago, then it stopped working, one day ago it started working again, and today it stopped working.
Code to open Place Picker:
private void openPlacePicker() {
Log.i(TAG, "open place picker");
PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
try {
startActivityForResult(builder.build(this), PLACE_PICKER_REQUEST);
}
catch (GooglePlayServicesRepairableException | GooglePlayServicesNotAvailableException e) {
e.printStackTrace();
}
}
And yes I've added a permission check for ACCESS_FINE_LOCATION, before executing the function.
Code for on Activity Result:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.i(TAG, "onActivityResult");
if (requestCode == PLACE_PICKER_REQUEST) {
if (resultCode == RESULT_OK) {
final Place place = PlacePicker.getPlace(this, data);
(...)
My logs don't show any errors, and the OnActivityResult Logs aren't called:
D/libgps: proxy_gps_stop: called.
D/libgps: proxy_gps_status_cb: called.
D/libgps: proxy_gps_status_cb: called.
I/art: Background partial concurrent mark sweep GC freed 58725(4MB) AllocSpace objects, 23(2MB) LOS objects, 40% free, 14MB/23MB, paused 1.422ms total 101.850ms
D/gpsd: WakeLock(Release,GPSD)
I/Auth: [AuthDelegateWrapper] Service intent: Intent { cmp=com.google.android.gms/.auth.account.authenticator.DefaultAuthDelegateService }.
I/Auth: [AuthDelegateWrapper] Service intent: Intent { cmp=com.google.android.gms/.auth.account.authenticator.DefaultAuthDelegateService }.
I/Auth: [AuthDelegateWrapper] Service intent: Intent { cmp=com.google.android.gms/.auth.account.authenticator.DefaultAuthDelegateService }.
D/NetworkSecurityConfig: No Network Security Config specified, using platform default
I/GCoreUlr: Successfully inserted 1 locations
I/WifiHAL: Got channel list with 11 channels
I/WifiHAL: Got channel list with 9 channels
I/WifiHAL: Got channel list with 13 channels
W/ActivityManager: Launch timeout has expired, giving up wake lock!
My Manifest Meta Data and Permissions:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<application
(...)
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIza(...)" />
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
I've check in the Google Console Page, the package name and the SHA-1 fingerprint are correct.
When I'm at Overview > Google Maps APIs > Google Places API for Android > Usage, it shows no usage what so ever, when it should be showing some, because as I said previously, one day ago it was working and I used it.
This issue has happen on my Nexus 9 (Android N), and on the Moto G3 (Android M).
Note: On the Moto G it would work the first time, user would click a button, place picker opens, user clicks on picker's "Select Location" button, goes to previous activity everything works fine; but if he clicks on the button to open the picker again, and he tries to click on picker's "Select Location" button again, he would go to the blank screen, and would have to close the app and try again).
TLDR;
The Place Picker in my android app goes to a blank screen when I try to select a location or leave the Place Picker Activity.
Thanks
As noted by my earlier comment, I had the exact same problem earlier today.
What solved it for me was replacing:
compile 'com.google.android.gms:play-services:9.0.0'
with
compile 'com.google.android.gms:play-services-location:9.0.0'
This change was suggested from this Stack post
Note: If you're using more than just the location from the play-services library, make sure to include the other components like
compile "com.google.android.gms:play-services-games:9.0.0"
compile "com.google.android.gms:play-services-plus:9.0.0"
compile "com.google.android.gms:play-services-ads:9.0.0"
This error timeout has expired, giving up wake lock! means your Activity is taking to long to start. If you are doing a lot of processing on the UI thread, Android kills your application. You should use AsyncTask for any processing intensive stuff. Activity cannot be displayed because it is still trying to complete execution; meanwhile the ActivityManager has timed out.
AsyncTask enables proper and easy use of the UI thread. This class allows to perform background operations and publish results on the UI thread without having to manipulate threads and/or handlers.
Sample implementation of Asyntask:
private class DownloadFilesTask extends AsyncTask<URL, Integer, Long> {
protected Long doInBackground(URL... urls) {
}
protected void onProgressUpdate(Integer... progress) {
}
protected void onPostExecute(Long result) {
}
}
For blank screen when selecting locations, make sure you have the permission in your manifest file.
uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/ >
uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>