發送意圖廣播接收器我有廣播接收器類:亞行
public class IntentReceiver extends BroadcastReceiver {
final String tag = "Intent Intercepter";
@Override
public void onReceive(Context context, Intent intent) {
try {
String data = intent.getStringExtra("sms_body");
Log.i(tag, data);
Toast.makeText(context, data.subSequence(0, data.length()), Toast.LENGTH_LONG).show();
} catch (Exception e) {
Toast.makeText(context, "Intercepted", Toast.LENGTH_LONG).show();
}
}
}
而且還表現在:
<receiver android:name="com.whereismywifeserver.IntentReceiver" android:enabled="true">
<intent-filter android:priority="999">
<action android:name="com.whereismywifeserver.intent.TEST"/>
</intent-filter>
</receiver>
但是,當我嘗試從亞行派的意圖,我收到錯誤:
C:\Users\i.yesilevsky>adb shell am start -a com.whereismywifeserver.intent.TEST
--es sms_body "test from adb" -c android.intent.category.HOME -n com.whereismywifeserver/.IntentReceiver
Starting: Intent { act=com.whereismywifeserver.intent.TEST t=[android.intent.category.HOME] cmp=com.whereismywifeserver/.IntentReceiver (has extras) }
Error type 3
Error: Activity class {com.whereismywifeserver/com.whereismywifeser
ver.IntentReceiver} does not exist.
當我在代碼中創建意圖時,一切正常。那麼我怎麼能從adb發送意圖呢?
可能重複(http://stackoverflow.com/questions/10277796/send-intent-to-app-in-emulator) – janot
你終於找到她嗎? – Jmorvan