我正在尝试“模拟”重新启动(或任何其他带有 的adb shell am
)并且无法弄清楚如何引用我的组件。再说一次,也许我什至不明白组件是什么意思。下面我首先包含一些不起作用的示例命令,然后是我的清单。请注意,当“电话”启动时,成功调用了 StartupReceiver。我只想在不完全重启的情况下重新触发它。
失败的 ADB 命令:
$ ./adb shell am broadcast -a android.intent.action.BOOT_COMPLETED -c android.intent.category.HOME -n net.fstab.checkit_android.StartupReceiver
<help snipped>
Error: Bad component name: net.fstab.checkit_android.StartupReceiver
$ ./adb shell am broadcast -a android.intent.action.BOOT_COMPLETED -c android.intent.category.HOME -n .StartupReceiver
<help snipped>
Error: Bad component name: .StartupReceiver
$ ./adb shell am broadcast -a android.intent.action.BOOT_COMPLETED -c android.intent.category.HOME -n StartupReceiver
<help snipped>
Error: Bad component name: StartupReceiver
显现:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.fstab.checkit_android" android:installLocation="internalOnly"
android:versionCode="1" android:versionName="1.0">
<application android:icon="@drawable/icon"
android:label="@string/app_name">
<activity android:name=".BaseActivity" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="BasePreferences" />
<activity android:name="EditActivity" />
<receiver android:name="StartupReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.HOME" />
</intent-filter>
</receiver>
<receiver android:name="NotificationReceiver">
<intent-filter>
<action android:name="net.fstab.checkit_android.NotificationReceiver" />
</intent-filter>
</receiver>
<service android:name="StartupService">
<intent-filter>
<action android:name="net.fstab.checkit_android.StartupService" />
</intent-filter>
</service>
</application>
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
</manifest>