我目前正在試圖製作一個廣播接收器,它會在android設備啓動後調用,然後運行後臺服務。我嘗試過很多例子,但不知道我要去哪裏錯。我正在關注這個例子: https://github.com/commonsguy/cw-advandroid/tree/master/SystemEvents/OnBoot 我已經將這個整個項目導入到我的工作區中並試圖運行。但接收方沒有調用。 請幫我一把。 我測試裝置:Motorolla的Xoom與ICS 4.0.3Android引導廣播沒有調用
編輯
清單
<uses-sdk android:minSdkVersion="8" />
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.REBOOT" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<service
android:name="awais.soft.MyService"
android:enabled="true" >
<intent-filter>
<action android:name="awais.soft.MyService" >
</action>
</intent-filter>
</service>
<receiver android:name="awais.soft.ServicesDemoActivity" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" >
</action>
<category android:name="android.intent.category.HOME" >
</category>
</intent-filter>
</receiver>
</application>
廣播接收機
package awais.soft;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.Menu;
public class ServicesDemoActivity extends BroadcastReceiver {
static final int idBut = Menu.FIRST + 1, idIntentID = Menu.FIRST + 2;
@Override
public void onReceive(Context context, Intent intent) {
Log.e("Awais", "onReceive:");
if (intent.getAction().equals(Intent.ACTION_POWER_CONNECTED)) {
Intent i = new Intent();
i.setAction("awais.kpsoft.MyService");
context.startService(i);
}
}
}
服務
}
這是後來的錯誤類型錯誤。 – 2012-02-24 07:04:27
請發表您的編輯代碼,以便我可以得到 – 2012-02-24 07:05:39