的BootReceiver从来没有所谓即使系统使用此命令是开机:为什么BroadcastReceiver没有被呼叫?
亚行外壳AM广播-a -n android.intent.action.BOOT_COMPLETED com.android.canbedeleted.test/.BootReceiver
权限我已经把清单:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.android.canbedeleted.test">
<uses-sdk android:minSdkVersion="15" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application android:label="test">
<receiver android:name="test.Droid.BootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
</application>
接收器标签我曾尝试删除它,但没有看到任何不同。
[BroadcastReceiver]
[IntentFilter (new string[] { Intent.ActionBootCompleted }, Priority = (int)IntentFilterPriority.HighPriority)]
public class BootReceiver : BroadcastReceiver
{
public override void OnReceive(Context context, Intent intent)
{
System.Diagnostics.Debug.WriteLine ("*********************************** Broadcast Received *********************************");
Toast.MakeText(context, "Received intent!", ToastLength.Short).Show();
//Intent message = new Intent();
//message.AddFlags(ActivityFlags.NewTask);
//message.SetClass(context, typeof(KeyboardService));
//context.StartService(intent);
}
}
即使我试图像这样键入cmd,我将有如下的堆栈跟踪。 test.Droid是该类的名称空间。
亚行外壳AM广播-a -n android.intent.action.BOOT_COMPLETED com.android.canbedeleted.test/test.Droid.BootReceiver
堆栈跟踪
的java.lang .RuntimeException:无法实例化接收器test.Droid.BootReceiver:java.lang.ClassNotFoundException:在路径中找不到类“test.Droid.BootReceiver”:DexPathList [[zip file] /data/app/com.android.canbedeleted .test-8.apk“],nativeLibraryDirectories = [/ data/app-lib/com.android.canbedeleted.test-8,/ vendor/lib,/系统/ lib]] ---> Java.Lang.ClassNotFoundException:在路径中找不到类“test.Droid.BootReceiver”:DexPathList [[zip file] /data/app/com.android.canbedeleted.test-8 .apk“],nativeLibraryDirectories = [/ data/app-lib/com.android.canbedeleted.test-8,/ vendor/lib,/ system/lib] at java.lang.ClassNotFoundException:找不到类” test.Droid.BootReceiver“的路径:DexPathList [[zip文件”/data/app/com.android.canbedeleted.test-8.apk"],nativeLibraryDirectories=[/data/app-lib/com.android.canbedeleted。 test-8,/ vendor/lib,/ system/lib]] atat at java.lang.ClassLoader.loadClass(ClassLoader.java:457) at at android.app.ActivityThread.handleReceiver(ActivityThread.java:2513) at at android.app.ActivityThread.access $ 1800(ActivityThread.java:161) at android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1341) at at android.os.Handler.dispatchMessage(Handler。 java:102) at at android.os.Looper.loop(Looper.java:157) at android.app.ActivityThread.main(ActivityThread.java:5356) at at java.lang.reflect.Method.invokeNative (Native Method) at at java.lang.reflect.Method.invoke(Method.java:515) at at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1265) at at com .android.internal.os.ZygoteInit.main(ZygoteInit.java:1081) at at dalvik.system.NativeStart.main(Native Method) ---内部异常结束st ack trace --- at java.lang.RuntimeException:无法实例化接收器test.Droid.BootReceiver:java.lang.ClassNotFoundException:在路径中找不到类“test.Droid.BootReceiver”:DexPathList [[zip file] /data/app/com.android.canbedeleted.test-8.apk"],nativeLibraryDirectories=[/data/app-lib/com.android.canbedeleted.test-8,/ vendor/lib,/ system/lib]] at at android.app.ActivityThread.handleReceiver(ActivityThread。java:2518) at at android.app.ActivityThread.access $ 1800(ActivityThread.java:161) at at android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1341) at at android.os.Handler。 dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:157) at android.app.ActivityThread.main(ActivityThread.java:5356) at at java.lang.reflect .Method.invokeNative(本地方法) at at java.lang.reflect.Method.invoke(Method.java:515) at at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1265) at at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081) at at dalvik.system.NativeStart.main(Native Method) 在导致:java.lang.ClassNotFoundException:没有找到类“test.Droid.BootReceiver”的路径:DexPathList [[zip文件“/ data/app/com.android.canbedeleted.test-8.apk”] ,nativeLibraryDirectories = [/ data/app-lib/com.android.canbedeleted.test-8,/ vendor/lib,/ system/lib]]在dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:67) at at java.lang.ClassLoader.loadClass(ClassLoader.java:497) at at java.lang.ClassLoader.loadClass(ClassLoader.java:457) at at android.app.ActivityThread.handleReceiver(ActivityThread.java:2513) at ... 10更多
看看http://stackoverflow.com/questions/39713862/xamarin-form-android-doesnt-received-the-broadcast-after-reboot/39714163#39714163 – SushiHangover
我从不强迫应用程序关闭。我甚至有屏幕上显示的活动 – LittleFunny
看看你的*生成的清单和实际包含的类名称。 – SushiHangover