我有,只要它沒有找到任何連接它打開了我的濺活動說:「沒有網絡連接」 ......到現在爲止一切都很好,但接收互聯網connectivity..and廣播接收器,當用戶放使用設備主頁按鈕將應用程序拖放到背景中,然後關閉互聯網連接,當應用程序在後臺運行時,splash活動進入前臺。我不想讓這種情況發生,但是隻能在後臺打開。當應用程序在後臺時,廣播接收器在前臺打開活動?
@Override
public void onReceive(Context context, Intent intent) {
// SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean isNetworkDown = intent.getBooleanExtra(
ConnectivityManager.EXTRA_NO_CONNECTIVITY, false);
if (isNetworkDown) {
Log.d(TAG, "onReceive: NOT connected, stopping UpdaterService");
Intent myintent=new Intent(context,NoConnectivity.class);
myintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(myintent);
} else
{
Log.d(TAG, "onReceive: connected, starting UpdaterService");
NoConnectivity.h.sendEmptyMessage(0);
}
}
請發表您的廣播接收器的代碼。 – Erol 2012-07-11 05:48:42
我已經發布了它的最新資訊,PLZ – Ishant 2012-07-11 05:52:18