您好,我一直在試圖創建一個廣播接收器,但我無法調用它,即從應用程序啓動時啓動它,這裏是我的代碼,請告訴我,是否有東西丟失或不在這裏是我嘗試到現在爲止的事情無法在應用程序啓動時調用廣播接收器
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.testing.broacast" android:versionCode="1" android:versionName="1.0" android:installLocation="auto">
<uses-sdk android:minSdkVersion="16" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application android:label="App4"></application>
<receiver android:name=".Broadcast">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
</manifest>
這裏是我的廣播reciever
[BroadcastReceiver]
[IntentFilter(new[] { Intent.ActionBootCompleted })]
public class Broadcast : BroadcastReceiver
{
public override void OnReceive(Context context,Intent intent)
{
Toast.MakeText(context, "Hello", ToastLength.Long).Show();
// Create your application here}
}
}
您正在使用啓動完成的廣播接收器,只有在重新啓動後才能獲得處理。這是你的意思嗎?但是我無法稱之爲從應用程序啓動開始呢? – Skynet
@MikeM。你好邁克我開始我的申請至少一次,這樣我就可以開始廣播接收者 –
@Skynet不,我想開始我的服務,只要我的應用程序一旦開始就像在水龍頭上,它應該連續運行在後面 –