public static boolean getBooleanExtra(Intent intent, String name, boolean defaultValue) { if (null == intent) { return defaultValue; } boolean ret = defaultValue; try { ret = intent.getBooleanExtra(name, defaultValue); } catch (Exception e) { Log.e(TAG, "getBooleanExtra exception:" + e.getMessage()); ret = defaultValue; } return ret; }
@Override public void onReceive(Context context, Intent intent) { if (intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, false)) { handleConnectivityChange(null); return; } handleConnectivityChange(intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO)); } };
private String getEventLabel(Intent event) { if (event.getAction()==null) { return("explicit"); } else if (event.getBooleanExtra(TestReceiver.EXTRA_IS_FANOUT, false)) { return("fanout"); } return("implicit"); } }
@Override public void onReceive(Context context, Intent intent) { final String action = intent.getAction(); if (action.equals(WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION)) { if (intent.getBooleanExtra(WifiManager.EXTRA_SUPPLICANT_CONNECTED, false)){ //do stuff } else { // wifi connection was lost } } }
@Override public int onStartCommand(Intent intent, int flags, int startId) { String playlist=intent.getStringExtra(EXTRA_PLAYLIST); boolean useShuffle=intent.getBooleanExtra(EXTRA_SHUFFLE, false); play(playlist, useShuffle); return(START_NOT_STICKY); }
public class NetworkStateReceiver extends BroadcastReceiver { public void onReceive(Context context, Intent intent) { Log.d("app","Network connectivity change"); if(intent.getExtras()!=null) { NetworkInfo ni=(NetworkInfo) intent.getExtras().get(ConnectivityManager.EXTRA_NETWORK_INFO); if(ni!=null && ni.getState()==NetworkInfo.State.CONNECTED) { Log.i("app","Network "+ni.getTypeName()+" connected"); } else if(intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY,Boolean.FALSE)) { Log.d("app","There's no network connectivity"); } } }
@Override protected void onHandleIntent(Intent intent) { if (Intent.ACTION_OPEN_DOCUMENT.equals(intent.getAction())) { load(intent.getData()); } else if (Intent.ACTION_EDIT.equals(intent.getAction())) { save(intent.getData(), intent.getStringExtra(Intent.EXTRA_TEXT), intent.getBooleanExtra(EXTRA_CLOSING, false)); } }
@Override public void onHandleWork(Intent i) { Log.d(getClass().getSimpleName(), "scheduled work begins"); if (i.getBooleanExtra(PollReceiver.EXTRA_IS_DOWNLOAD, false)) { new DownloadJob().run(); // do synchronously, as we are on // a background thread already } Log.d(getClass().getSimpleName(), "scheduled work ends"); } }
@Override public void onHandleWork(Intent i) { Log.d(getClass().getSimpleName(), "scheduled work begins"); if (i.getBooleanExtra(PollReceiver.EXTRA_IS_DOWNLOAD, false)) { new DownloadJob().run(); // do synchronously, as we are on // a background thread already } Log.d(getClass().getSimpleName(), "scheduled work ends"); } }
@Override public int onStartCommand(Intent intent, int flags, int startId) { Log.d("DemoService", "onStartCommand()"); boolean foreground=intent.getBooleanExtra(EXTRA_FOREGROUND, false); boolean importantish=intent.getBooleanExtra(EXTRA_IMPORTANTISH, false); if (foreground) { String channel=importantish ? CHANNEL_LOW : CHANNEL_MIN; startForeground(1337, buildForegroundNotification(channel)); } return(super.onStartCommand(intent, flags, startId)); }
@Override public void initToolBar() { mIsDiscussion = getIntent().getBooleanExtra(INTENT_DIS, false); if (mIsDiscussion) { mCommonToolbar.setTitle("综合讨论区"); } else { mCommonToolbar.setTitle("原创区"); } mCommonToolbar.setNavigationIcon(R.drawable.ab_back); }
@Override protected void onHandleIntent(Intent intent) { if (intent == null) return; if (ACTION_POST_NEW_STORY.equals(intent.getAction())) { final boolean broadcastResult = intent.getBooleanExtra(EXTRA_BROADCAST_RESULT, false); if (!repository.isLoggedIn()) return; // shouldn't happen... final String title = intent.getStringExtra(EXTRA_STORY_TITLE); final String url = intent.getStringExtra(EXTRA_STORY_URL); final String comment = intent.getStringExtra(EXTRA_STORY_COMMENT); if (TextUtils.isEmpty(title)) return; NewStoryRequest storyToPost = getNewStoryRequest(title, url, comment); if (storyToPost == null) return; postStory(broadcastResult, service, repository.getUser(), storyToPost); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_play_pick); ButterKnife.bind(this); isTransition = getIntent().getBooleanExtra(TRANSITION, false); init(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_play_empty_control); ButterKnife.bind(this); isTransition = getIntent().getBooleanExtra(TRANSITION, false); init(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_play); ButterKnife.bind(this); isTransition = getIntent().getBooleanExtra(TRANSITION, false); init(); }
@Override public void onReceive(Context ctxt, Intent i) { boolean isDownload=i.getBooleanExtra(EXTRA_IS_DOWNLOAD, false); DemoScheduledService.enqueueWork(ctxt, new Intent(ctxt, DemoScheduledService.class) .putExtra(EXTRA_IS_DOWNLOAD, isDownload)); long period=i.getLongExtra(EXTRA_PERIOD, -1); if (period>0) { scheduleExactAlarm(ctxt, (AlarmManager)ctxt.getSystemService(Context.ALARM_SERVICE), period, isDownload); } }
@Override public void onReceive(Context ctxt, Intent i) { boolean isDownload=i.getBooleanExtra(EXTRA_IS_DOWNLOAD, false); DemoScheduledService.enqueueWork(ctxt, new Intent(ctxt, DemoScheduledService.class) .putExtra(EXTRA_IS_DOWNLOAD, isDownload)); long period=i.getLongExtra(EXTRA_PERIOD, -1); if (period>0) { scheduleExactAlarm(ctxt, (AlarmManager)ctxt.getSystemService(Context.ALARM_SERVICE), period, isDownload); } }
@Override public int onStartCommand(Intent intent, int flags, int startId) { if (intent.hasExtra(EXTRA_ACRA_CONFIG)) { final boolean onlySendSilentReports = intent.getBooleanExtra(EXTRA_ONLY_SEND_SILENT_REPORTS, false); final CoreConfiguration config = (CoreConfiguration) intent.getSerializableExtra(EXTRA_ACRA_CONFIG); new SendingConductor(this, config).sendReports(onlySendSilentReports); } else { if (ACRA.DEV_LOGGING) ACRA.log.d(LOG_TAG, "SenderService was started but no valid intent was delivered, will now quit"); } return START_REDELIVER_INTENT; }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setLayout(R.layout.account_setup_account_type); findViewById(R.id.pop).setOnClickListener(this); findViewById(R.id.imap).setOnClickListener(this); findViewById(R.id.webdav).setOnClickListener(this); String accountUuid = getIntent().getStringExtra(EXTRA_ACCOUNT); mAccount = Preferences.getPreferences(this).getAccount(accountUuid); mMakeDefault = getIntent().getBooleanExtra(EXTRA_MAKE_DEFAULT, false); }
public void testAsPngSetAsExtras() { builder.asPng(true); Intent intent = builder.getIntent(activity); assertThat(intent.getBooleanExtra("as_png", false)).isEqualTo(true); } }