I'm using Android policy manager and the following code works on Android 5.0.x mobile devices.
Intent deviceAdminIntent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
deviceAdminIntent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, cdmDeviceAdmin);
deviceAdminIntent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION,
getResources().getString(R.string.device_admin_enable_alert));
startActivityForResult(deviceAdminIntent, ACTIVATION_REQUEST);
However, when I deploying the same on Android TV image with the same OS version, it throws the following exception.What could be the issue? Where can I find the source1 for Android TV images?
E/AgentApplication: UncaughtExceptionHandler got an exception
java.lang.RuntimeException: Unable to start activity ComponentInfo{xxxxx}: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.app.action.ADD_DEVICE_ADMIN (has extras) }
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.app.action.ADD_DEVICE_ADMIN (has extras) }
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1798)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1512)
at android.app.Activity.startActivityForResult(Activity.java:3917)
at android.app.Activity.startActivityForResult(Activity.java:3877)
1. https://github.com/android/platform_frameworks_base/blob/master/core/java/android/app/admin/DevicePolicyManager.java
Related
This question already has answers here:
android app crash on android 4.4 due to gps permission denial
(2 answers)
Closed 6 years ago.
This is my code:
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent intent = new Intent("android.location.GPS_ENABLED_CHANGE");
intent.putExtra("enabled", true);
sendBroadcast(intent);
}
}
This is the error in logcat:
FATAL EXCEPTION: main
Process: com.example.satyajittarafdar.gps_on_automatic, PID: 20469
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.example.satyajittarafdar.gps_on_automatic/com.example.satyajittarafdar.gps_on_automatic.MainActivity}:
java.lang.SecurityException: Permission Denial: not allowed to send
broadcast android.location.GPS_ENABLED_CHANGE from pid=20469,
uid=10240
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2429)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2493)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1357)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5459)
at java.lang.reflect.Method.invoke(Native Method)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
Caused by: java.lang.SecurityException: Permission Denial: not allowed
to send broadcast android.location.GPS_ENABLED_CHANGE from pid=20469,
uid=10240
at android.os.Parcel.readException(Parcel.java:1620)
at android.os.Parcel.readException(Parcel.java:1573)
at
android.app.ActivityManagerProxy.broadcastIntent(ActivityManagerNative.java:3128)
at android.app.ContextImpl.sendBroadcast(ContextImpl.java:767)
at
android.content.ContextWrapper.sendBroadcast(ContextWrapper.java:396)
at
com.example.satyajittarafdar.gps_on_automatic.MainActivity.onCreate(MainActivity.java:19)
at android.app.Activity.performCreate(Activity.java:6259)
at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1130)
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2382)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2493)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1357)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5459)
at java.lang.reflect.Method.invoke(Native Method)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
This is not available as public API, and you cannot change GPS state programmatically from Android 4.4 and above. you have prepare intent and redirect user to settings.
startActivity(context, new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS));
here are some references:
https://stackoverflow.com/a/22529296/3758024
https://stackoverflow.com/a/20236331/3758024
You cannot change the gps state programmaticly since android version 4.4.
Good explanation why: Read this post
What you should so is using intent to send the user to the phoen setting and request him to enable it manually.
Fatal Exception: java.lang.SecurityException: Unable to start service Intent { act=com.google.firebase.crash.internal.service.FirebaseCrashReceiverService.SAVE cmp=com.sample.android/com.google.firebase.crash.internal.service.FirebaseCrashReceiverService (has extras) }: Unable to launch app com.sample.android/10124 for service Intent { act=com.google.firebase.crash.internal.service.FirebaseCrashReceiverService.SAVE cmp=com.sample.android/com.google.firebase.crash.internal.service.FirebaseCrashReceiverService }: process is bad
at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1720)
at android.app.ContextImpl.startService(ContextImpl.java:1693)
at android.content.ContextWrapper.startService(ContextWrapper.java:516)
at aii.run(:com.google.android.gms.DynamiteModulesC:181)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Firebase crash is set up perfectly as we are getting reports of the crashes BUT i'm seeing this on Crashlytics and this ultimately leads to crashing the app.
Does anyone know what this problem is?
I get the following error when I try to luanch my Angular app in my android app.
06-15 13:49:15.037 9055-9055/? E/AppInfoBase: Exception when retrieving package:com.myPackage
android.content.pm.PackageManager$NameNotFoundException: com.myPackage
at android.app.ApplicationPackageManager.getPackageInfo(ApplicationPackageManager.java:137)
at com.android.settings.applications.AppInfoBase.retrieveAppEntry(AppInfoBase.java:123)
at com.android.settings.applications.InstalledAppDetails.refreshUi(InstalledAppDetails.java:466)
at com.android.settings.applications.InstalledAppDetails.onActivityResult(InstalledAppDetails.java:435)
at android.app.Activity.dispatchActivityResult(Activity.java:6452)
at android.app.ActivityThread.deliverResults(ActivityThread.java:3695)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:3742)
at android.app.ActivityThread.-wrap16(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1393)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
06-15 13:49:15.110 1900-1900/? E/NetworkScheduler.SchedulerReceiver: Invalid package name : Perhaps you didn't include a PendingIntent in the extras?
What is the issue? Unable to debug and trace :( I see the Android manifets file, its proper!
I am starting different apps like phone app, browser app, maps app from my app something like this
String url = "http://www." + textView.getText().toString();
Log.d(TAG,url);
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
mContext.startActivity(i);
At first they worked perfectly but now every app crashes like
"unfortunetly chorme stopped working" or "unfortunetly dialer has stopped working" etc. I hope some one knows why its happening. Thanks in advance.
This is my logcat
05-08 19:12:28.720 10227-10227/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.google.android.apps.maps, PID: 10227
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.google.android.apps.maps/com.google.android.maps.MapsActivity}: android.os.BadParcelableException: ClassNotFoundException when unmarshalling: com.example.krishnateja.bigapplesearch.models.MTAMainScreenModel
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2314)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2388)
at android.app.ActivityThread.access$800(ActivityThread.java:148)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5312)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696)
Caused by: android.os.BadParcelableException: ClassNotFoundException when unmarshalling: com.example.krishnateja.bigapplesearch.models.MTAMainScreenModel
at android.os.Parcel.readParcelableCreator(Parcel.java:2289)
at android.os.Parcel.readParcelable(Parcel.java:2239)
at android.os.Parcel.readValue(Parcel.java:2146)
at android.os.Parcel.readListInternal(Parcel.java:2520)
at android.os.Parcel.readArrayList(Parcel.java:1836)
at android.os.Parcel.readValue(Parcel.java:2167)
at android.os.Parcel.readArrayMapInternal(Parcel.java:2479)
at android.os.BaseBundle.unparcel(BaseBundle.java:221)
at android.os.BaseBundle.getIntArray(BaseBundle.java:1164)
at android.content.Intent.getIntArrayExtra(Intent.java:5004)
at com.google.android.apps.gmm.m.l.a(PG:1061)
at com.google.android.apps.gmm.m.w.a(PG:2241)
at com.google.android.apps.gmm.base.activities.a.onNewIntent(PG:953)
at com.google.android.apps.gmm.base.activities.a.onCreate(PG:641)
at android.app.Activity.performCreate(Activity.java:5953)
at
The reason for the class not found is I am overiding start activity for some other intent but I did not have an if condition saying add extra to the particular intent. A silly mistake.
This issue is happening on Android 5.0 Lollipop only. I dont have access to a phone with Lollipop, I have developed the code in Genymotion Android Emulator but this issue does not happen in the emulator. I am only getting failing stacktraces from users' phones.
My Code:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Intent intent = new Intent(Settings.ACTION_USAGE_ACCESS_SETTINGS);
startActivity(intent);
}
The App crashes and the stacktrace I am getting from users:
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.settings.USAGE_ACCESS_SETTINGS }
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1765)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1485)
at android.app.Activity.startActivityForResult(Activity.java:3780)
at android.app.Activity.startActivityForResult(Activity.java:3741)
at android.support.v4.app.FragmentActivity.startActivityFromFragment(FragmentActivity.java:849)
at android.support.v4.app.Fragment.startActivity(Fragment.java:880)
at com.myapp.myfirstapp.fragments.addablock.apps.Fragment_appsselect_addblock$2.onClick(Fragment_ appsselect_addblock.java:147)
at android.view.View.performClick(View.java:4763)
at android.view.View$PerformClick.run(View.java:19821)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5274)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
I am seeing this crash too. It seems that LG has removed the newly introduced Usage Permission Setttings screen from their version of Lollipop.