Android Live Wallpaper crashes on Amazon App Store Testing ActivityNotFoundException - android

I am trying to put my live wallpaper on Amazon App Store(This live wallpaper is already live on Google Play Store), However, when I uploaded same APK for testing on Amazon Developer site it reports following exception
03-06 06:00:50.741 7598 7598 E AndroidRuntime: FATAL EXCEPTION: main
03-06 06:00:50.741 7598 7598 E AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.rrapps.heavensdoor/com.rrapps.heavensdoor.PreviewActivity}: android.content.ActivityNotFoundException: No Activity found to handle act=android.service.wallpaper.CHANGE_LIVE_WALLPAPER (has extras)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2229)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2283)
at android.app.ActivityThread.access$600(ActivityThread.java:148)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1244)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:151)
at android.app.ActivityThread.main(ActivityThread.java:5204)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.content.ActivityNotFoundException: No Activity found to handle act=android.service.wallpaper.CHANGE_LIVE_WALLPAPER (has extras)
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1627)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1417)
at android.app.Activity.startActivityForResult(Activity.java:3424)
at android.app.Activity.startActivityForResult(Activity.java:3385)
at com.rrapps.heavensdoor.PreviewActivity.onCreate(Unknown Source)
at android.app.Activity.performCreate(Activity.java:5170)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2182)
following is code where I am setting wallpaper
if (Build.VERSION.SDK_INT >= 16) {
/*
* Open live wallpaper preview (API Level 16 or greater).
*/
intent.setAction(WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER);
String pkg = MyWallpaperService.class.getPackage().getName();
String cls = MyWallpaperService.class.getCanonicalName();
intent.putExtra(WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT,
new ComponentName(pkg, cls));
} else {
/*
* Open live wallpaper picker (API Level 15 or lower).
*
* Display a quick little message (toast) with instructions.
*/
intent.setAction(WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER);
Resources res = getResources();
String hint = res.getString(R.string.picker_toast_prefix)
+ res.getString(R.string.lwp_name)
+ res.getString(R.string.picker_toast_suffix);
Toast toast = Toast.makeText(this, hint, Toast.LENGTH_LONG);
toast.show();
}
startActivityForResult(intent, 0);
I am not sure what the problem is. Any help is appreciated.

Android is a funny world and implicit intents unfortunately, vary more than we (developers) would like them to. Specially for Amazon devices, that are not required to comply with Google test suite. On my app, I've seen ActivityNotFoundException trying to launch the web-browser.
So my suggestion, even tho it doesn't actually fix the issue, it's just try catch it:
try{
startActivityForResult(intent, 0);
} catch(ActivityNotFoundException e) {
// why amazon, why?
}

Related

Sharing audio file with WhatsApp fails on Android 4.2

I am failing to share an audio file with WhatsApp on an Android Jelly Bean emulator. My code currently works on Lollipop and higher versions but I couldn't figure out why this error occurs on lower devices.
val share = Intent(Intent.ACTION_SEND)
share.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
//Audio MIME type
share.type = "audio/*"
//File uri (from file provider on api level 24 or higher)
share.putExtra(Intent.EXTRA_STREAM, fileUri(context))
context.startActivity(Intent.createChooser(share, context.getString(R.string.share_title)))
inside fileUri method
if (Build.VERSION.SDK_INT < 24)
return Uri.fromFile(this)
return FileProvider.getUriForFile(context, context.applicationContext.packageName
+ ".[myprovidername].provider", this)
logs
04-21 19:08:25.653 2840-2840/com.whatsapp W/Bundle: Key android.intent.extra.STREAM expected ArrayList but value was a android.net.Uri$HierarchicalUri. The default value <null> was returned.
04-21 19:08:25.653 2840-2840/com.whatsapp W/Bundle: Attempt to cast generated internal exception:
java.lang.ClassCastException: android.net.Uri$HierarchicalUri cannot be cast to java.util.ArrayList
at android.os.Bundle.getParcelableArrayList(Bundle.java:1223)
at com.whatsapp.ContactPickerFragment.ga(:250573)
at com.whatsapp.ContactPickerFragment.a(:249616)
at c.j.a.u.a(:178380)
at c.j.a.u.f(:178956)
at c.j.a.u.a(:177973)
at c.j.a.u.b(:178772)
at c.j.a.u.j(:179098)
at c.j.a.j.onStart(:246644)
at c.a.a.m.onStart(:267332)
at d.f.qJ.onStart(:296953)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1164)
at android.app.Activity.performStart(Activity.java:5114)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2153)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5041)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)
That's probably because WhatsApp is requiring a list of Uris even if there's only one. Try returning something like this
ArrayList<Uri> uriList = new ArrayList<Uri>();
uriList.add(Uri.fromFile(this));
Instead of
Uri.fromFile(this)

Android : Missing EXTRA PAYPAL CONFIGURATION. To avoid this error, set EXTRA PAYPAL CONFIGURATION in both PayPalService, and the initializing activity

I am trying to use the paypal in a Android environment.
Once I call the PayPalMobile.renderSinglePaymentUI function, the application hangs and I get following errors:
java.lang.RuntimeException: Unable to start service com.paypal.android.sdk.payments.PayPalService#4191d328 with Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.demoPayPal.android/com.paypal.android.sdk.payments.PayPalService (has extras) }: java.lang.RuntimeException: Missing EXTRA_PAYPAL_CONFIGURATION. To avoid this error, set EXTRA_PAYPAL_CONFIGURATION in both PayPalService, and the initializing activity.
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2635)
at android.app.ActivityThread.access$1900(ActivityThread.java:145)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1307)
at android.os.Handler.dispatchMessage(Handler.java:119)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4873)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:528)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: Missing EXTRA_PAYPAL_CONFIGURATION. To avoid this error, set EXTRA_PAYPAL_CONFIGURATION in both PayPalService, and the initializing activity.
at com.paypal.android.sdk.payments.PayPalService.a(Unknown Source)
at com.paypal.android.sdk.payments.PayPalService.onStartCommand(Unknown Source)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2610)
... 10 more
Code:
String CONFIG_ENVIRONMENT = PayPalConfiguration.ENVIRONMENT_PRODUCTION;
String CONFIG_CLIENT_ID = activity.getResources().getString(R.string.paypal_clientID);
PayPalConfiguration config = new PayPalConfiguration().environment(CONFIG_ENVIRONMENT).clientId(CONFIG_CLIENT_ID).merchantPrivacyPolicyUri(Uri.parse("https://www.example.com/privacy")).merchantUserAgreementUri(Uri.parse("https://www.example.com/legal"));
PayPalPayment thingToBuy = getThingToBuy(PayPalPayment.PAYMENT_INTENT_SALE, amount, currency);
Intent intent = new Intent(activity, com.paypal.android.sdk.payments.PaymentActivity.class);
intent.putExtra(PayPalService.EXTRA_PAYPAL_CONFIGURATION, config);
intent.putExtra(com.paypal.android.sdk.payments.PaymentActivity.EXTRA_PAYMENT, thingToBuy);
startActivityForResult(intent, MainActivity.REQUEST_CODE_PAYMENT);
Has anyone came across such a situation? Have you got anything to propose?
Thanks in advance.
actually this is due to your PayPalCofiguration object being null.
before starting the PayPalService, you are setting the EXTRA_PAYPAL_CONFIGURATION with putExtra. So if the config which youll pass here is null, the crash will happen. Check for your config being non null. That should solve the issue, Cheers.

SecurityException when calling BluetoothAdapter.getDefaultAdapter

In onCreate() of my app I call BluetoothAdapter.getAddress(). One single device of hundreds, that are running this app, yields a java.lang.SecurityException:
java.lang.RuntimeException: Unable to start activity
ComponentInfo{xx.yyy.myapp/xx.yyy.myapp.RecActivity}:
java.lang.SecurityException: Need BLUETOOTH ADMIN permission: Neither
user 10095 nor current process has android.permission.BLUETOOTH_ADMIN.
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
at android.app.ActivityThread.access$600(ActivityThread.java:141) at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
at android.os.Handler.dispatchMessage(Handler.java:99) at
android.os.Looper.loop(Looper.java:137) at
android.app.ActivityThread.main(ActivityThread.java:5039) at
java.lang.reflect.Method.invokeNative(Native Method) at
java.lang.reflect.Method.invoke(Method.java:511) at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) at
dalvik.system.NativeStart.main(Native Method) Caused by:
java.lang.SecurityException: Need BLUETOOTH ADMIN permission: Neither
user 10095 nor current process has android.permission.BLUETOOTH_ADMIN.
at android.os.Parcel.readException(Parcel.java:1425) at
android.os.Parcel.readException(Parcel.java:1379) at
android.bluetooth.IBluetoothManager$Stub$Proxy.getAddress(IBluetoothManager.java:295)
at
android.bluetooth.BluetoothAdapter.getAddress(BluetoothAdapter.java:576)
at xx.yyy.myapp.RecActivity.onCreate(Unknown Source) at
android.app.Activity.performCreate(Activity.java:5104) at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
... 11 more
As I can't debug on that device I would like to ask if the following solution is feasible or if there's a better way to handle the problem (this is the branch for less than JELLY_BEAN_MR2)?
BluetoothAdapter bta = BluetoothAdapter.getDefaultAdapter();
try {
macAddress = ( bta != null ) ? bta.getAddress() : "";
} catch ( Exception e ) {
macAddress = "";
}
Also, I wonder if the Android version on that device might have a bug as it seems to me that getAddress() in BluetoothAdapter.java doesn't require android.permission.BLUETOOTH_ADMIN?
Or is it possible that the user with this device has a specific root tool to lock bluetooth access from my app? And that this might be the reason for the Exception?
Or what might be the reason for the problem?
Since it's bad practice to use catch(Exception e), use
} catch(SecurityException e){
to prevent the crash.
(As an answer now instead of a comment.)

Android NullPointerException in Instrumentation.execStartActivity

I keep getting the bellow exception from some users:
java.lang.NullPointerException
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1414)
at android.app.Activity.startActivityForResult(Activity.java:2880)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:817)
at android.app.Activity.startActivity(Activity.java:2986)
at com.google.android.gms.internal.bb$5.onClick(Unknown Source)
at android.view.View.performClick(View.java:2535)
at android.view.View$PerformClick.run(View.java:9130)
at android.os.Handler.handleCallback(Handler.java:618)
at android.os.Handler.dispatchMessage(Handler.java:123)
at android.os.Looper.loop(SourceFile:351)
at android.app.ActivityThread.main(ActivityThread.java:3826)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:538)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:969)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:727)
at dalvik.system.NativeStart.main(Native Method)
I've found a similar problem here but it's not taken care of since April. All I know is that it was reproduced on a Samsung Galaxy Y (GT-S5360) and I'm using Google Maps Android API v2.
Do you have any idea how can I make a workaround for this?
I have the same error, I also use Google Maps API. It seems to happen on all Android versions and phones. Just to mention few:
AN10DG3, GT-I8190, F815, GT-I9300, GOOPHONE, HTC One, KFTT, MID8127, KFAPWI, AN10DG3
java.lang.NullPointerException
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1409)
at android.app.Activity.startActivityForResult(Activity.java:3351)
at android.app.Activity.startActivityForResult(Activity.java:3312)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:839)
at android.app.Activity.startActivity(Activity.java:3522)
at android.app.Activity.startActivity(Activity.java:3490)
at com.google.android.gms.dynamic.a$5.onClick(Unknown Source)
at android.view.View.performClick(View.java:4084)
at android.view.View$PerformClick.run(View.java:16966)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
as I read somewhere, solution is:
Above mentioned problem can occur if you have emulator or device in which google play services are not installed. I don't have perfect solution but I figured out some work around to save your app from crashing. In this case you have to follow simple steps
Override startActivityForResult(intent, requestcode)
In startActivityForResult add super call super.startActivityForResult in try catch and catch the NullPointerException
Easy its done Now you can trap the nullpointerexception here and add your error handling in catch
#Override
public void startActivityForResult(Intent intent, int requestCode) {
try {
super.startActivityForResult(intent, requestCode);
} catch (Exception e) {
// fixes Google Maps bug: http://stackoverflow.com/a/20905954/2075875
}
}
in my case crash in Instrumentation.java
line 1581,
android.util.SeempLog.record_str(377, intent.toString());
intent is null then NPE
not sure how to fix this

Error while executing API method: media.videoPlay using trigger.io

I'm trying to play video using trigger.io.
Code is following:
var urlString = "....mp4";
forge.tools.getURL(urlString, function (myUrl) {
forge.media.videoPlay(
myUrl,
function() {
alert("ok");
},
function(content) {
alert(content)
}
);
});
When I launch this application using IOS emulator it works. But when I try it on Android emulator I get following errors:
[WARNING] Error while executing API method: media.videoPlay
[DEBUG] Returned: {"content":{"message":"Forge Java error: ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat={link}https://s3-eu-west-1.amazonaws.com/braingasm-video/6bPLY7orbVY.mp4{/link} typ=video/* }","type":"UNEXPECTED_FAILURE","subtype":null,"full_error":"android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat={link}https://s3-eu-west-1.amazonaws.com/braingasm-video/6bPLY7orbVY.mp4{/link} typ=video/* }
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1408)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
at android.app.Activity.startActivityForResult(Activity.java:2817)
at android.app.Activity.startActivity(Activity.java:2923)
at io.trigger.forge.android.modules.media.API.videoPlay(API.java:13)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at io.trigger.forge.android.core.ForgeApp.callJavaFromJavaScript(ForgeApp.java:247)
at io.trigger.forge.android.core.ForgeJSBridge$1.run(ForgeJSBridge.java:17)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
at java.lang.Thread.run(Thread.java:1096)
"},"callid":"BB45C58C-BE4B-42A0-B76A-4EC6B388B850","status":"error"}
I'm not sure you can play videos on the Android emulator, what this error means is there is no app available to play the video. If you run the same code on a device it should use the built in video player.

Categories

Resources