此问题在此处已有答案:
How can I request permission from the user for autostart and for Battery saver(No restrictions) in Xamarin.Forms android?(1个答案)
三个月前关门了。
我需要检查xiaomi上的应用程序设置中的框,它的工作原理华为上出现错误。
我的验证码:
try
{
Intent intent = new Intent();
intent.SetComponent("com.huawei.systemmanager", "com.huawei.systemmanager.appcontrol.activity.StartupAppControlActivity"); // huawei
// intent.SetComponent(new ComponentName("com.miui.securitycenter", "com.miui.appmanager.ApplicationsDetailsActivity")); // xiaomy
intent.PutExtra("package_name", PackageName);
StartActivity(intent);
}
catch (Exception anfe)
{
}
我的例外
{Java.Lang.SecurityException: Permission Denial: starting Intent { cmp=com.huawei.systemmanager/.appcontrol.activity.StartupAppControlActivity (has extras) } from ProcessRecord{2f6f6d7 8007:com.companyname.corporate_messenger/u0a410} (pid=8007, uid=10410) requires com.huawei.permission.external_app_settings.USE_COMPONENT ---> Android.OS.RemoteException: Remote stack trace:
at com.android.server.wm.ActivityStackSupervisor.checkStartAnyActivityPermission(ActivityStackSupervisor.java:1209)
at com.android.server.wm.ActivityStarter.startActivity(ActivityStarter.java:924)
at com.android.server.wm.ActivityStarter.startActivity(ActivityStarter.java:674)
at com.android.server.wm.HwActivityStarter.startActivity(HwActivityStarter.java:278)
at com.android.server.wm.ActivityStarter.startActivityMayWait(ActivityStarter.java:1737)
callee: null 1665/2209
--- End of inner exception stack trace ---
at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x0008e] in <00c315a988634383b446eff646084784>:0
at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00063] in <00c315a988634383b446eff646084784>:0
at Android.Content.ContextWrapper.StartActivity (Android.Content.Intent intent) [0x00027] in /Users/builder/azdo/_work/1/s/xamarin-android/src/Mono.Android/obj/Release/monoandroid10/android-29/mcw/Android.Content.ContextWrapper.cs:3364
at Corporate_messenger.Droid.MainActivity.SetPermission (System.String param1, System.String param2) [0x00028] in D:\Project\Xamarin\Messanger\Corporate messenger\Corporate messenger.Android\MainActivity.cs:103
--- End of managed Java.Lang.SecurityException stack trace ---
java.lang.SecurityException: Permission Denial: starting Intent { cmp=com.huawei.systemmanager/.appcontrol.activity.StartupAppControlActivity (has extras) } from ProcessRecord{2f6f6d7 8007:com.companyname.corporate_messenger/u0a410} (pid=8007, uid=10410) requires com.huawei.permission.external_app_settings.USE_COMPONENT
at android.os.Parcel.createException(Parcel.java:2091)
at android.os.Parcel.readException(Parcel.java:2059)
at android.os.Parcel.readException(Parcel.java:2007)
at android.app.IActivityTaskManager$Stub$Proxy.startActivity(IActivityTaskManager.java:3908)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1738)
at android.app.Activity.startActivityForResult(Activity.java:5412)
at androidx.activity.ComponentActivity.startActivityForResult(ComponentActivity.java:597)
at android.app.Activity.startActivityForResult(Activity.java:5337)
at androidx.activity.ComponentActivity.startActivityForResult(ComponentActivity.java:583)
at android.app.Activity.startActivity(Activity.java:5819)
at android.app.Activity.startActivity(Activity.java:5787)
at crc6480b75fa72058fc63.MainActivity.n_onCreate(Native Method)
at crc6480b75fa72058fc63.MainActivity.onCreate(MainActivity.java:40)
at android.app.Activity.performCreate(Activity.java:8214)
at android.app.Activity.performCreate(Activity.java:8202)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1320)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4033)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4247)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:91)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:149)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:103)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2613)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:219)
at android.app.ActivityThread.main(ActivityThread.java:8668)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1109)
Caused by: android.os.RemoteException: Remote stack trace:
at com.android.server.wm.ActivityStackSupervisor.checkStartAnyActivityPermission(ActivityStackSupervisor.java:1209)
at com.android.server.wm.ActivityStarter.startActivity(ActivityStarter.java:924)
at com.android.server.wm.ActivityStarter.startActivity(ActivityStarter.java:674)
at com.android.server.wm.HwActivityStarter.startActivity(HwActivityStarter.java:278)
at com.android.server.wm.ActivityStarter.startActivityMayWait(ActivityStarter.java:1737)
callee: null 1665/2209
}
这个应用程序可以自己打开这个页面,基本上这个问题都是华为手机上出现的,目前我正在写一个安卓的应用程序,但是xamarin允许你写iOS的代码,所以以后我也会在那里添加这样的功能。
1条答案
按热度按时间vulvrdjw1#
好吧,它告诉你,在华为上你缺少一个许可:
{Java语言安全性异常:权限拒绝:从进程记录{2f 6 f6 d 7 8007:com.公司名称.公司信使/u 0a 410}(pid=8007,uid=10410)启动意图{ cmp=com.华为.系统管理器/.应用控制.活动.启动应用控制活动(有额外内容)}需要com.华为.权限.外部应用设置.USE_COMPONENT--〉Android.操作系统.远程异常:远程堆栈跟踪:
所以我猜你可以将这个权限添加到你的清单中,或者在你检测到你在使用华为手机时通过编程方式请求它。