Java Code Examples for android.content.Intent.hasExtra()
The following are Jave code examples for showing how to use
hasExtra() of the
android.content.Intent
class.
You can vote up the examples you like. Your votes will be used in our system to get
more good examples.
+ Save this method
Example 1
Project: Pocket-Plays-for-Twitch File: PlayerService.java View Source Code | 7 votes |
private void handleIntent( Intent intent ) { if( intent == null || intent.getAction() == null || mCallbacks == null) { return; } String action = intent.getAction(); if( action.equalsIgnoreCase( ACTION_PLAY ) ) { mCallbacks.onPlay(); } else if( action.equalsIgnoreCase( ACTION_PAUSE ) ) { mCallbacks.onPause(); } else if( action.equalsIgnoreCase( ACTION_FORWARD) ) { mCallbacks.onFastForward(); } else if( action.equalsIgnoreCase( ACTION_REWIND ) ) { mCallbacks.onRewind(); } else if( action.equalsIgnoreCase( ACTION_PREVIOUS ) ) { mCallbacks.onSkipToPrevious(); } else if( action.equalsIgnoreCase( ACTION_NEXT ) ) { mCallbacks.onSkipToNext(); } else if( action.equalsIgnoreCase( ACTION_STOP ) ) { mCallbacks.onStop(); } else if( action.equalsIgnoreCase( ACTION_SEEK ) && intent.hasExtra( VOD_PROGRESS ) ) { if (mp != null && mediaSession.isActive()) { mp.seekTo(intent.getIntExtra( VOD_PROGRESS, 0 )); } } }
Example 2
Project: Open-Quran-Radio File: InfosheetActivity.java View Source Code | 7 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // get activity title from intent Intent intent = this.getIntent(); // set activity title if (intent.hasExtra(TransistorKeys.EXTRA_INFOSHEET_TITLE)) { this.setTitle(intent.getStringExtra(TransistorKeys.EXTRA_INFOSHEET_TITLE)); } // set activity view if (intent.hasExtra(TransistorKeys.EXTRA_INFOSHEET_CONTENT) && intent.getIntExtra(TransistorKeys.EXTRA_INFOSHEET_CONTENT, -1) == TransistorKeys.INFOSHEET_CONTENT_ABOUT) { setContentView(R.layout.fragment_infosheet_about); } else if (intent.hasExtra(TransistorKeys.EXTRA_INFOSHEET_CONTENT) && intent.getIntExtra(TransistorKeys.EXTRA_INFOSHEET_CONTENT, -1) == TransistorKeys.INFOSHEET_CONTENT_HOWTO) { setContentView(R.layout.fragment_infosheet_howto); } }
Example 3
Project: ZxingForAndroid File: DecoratedBarcodeView.java View Source Code | 7 votes |
/** * Convenience method to initialize camera id, decode formats and prompt message from an intent. * * @param intent the intent, as generated by IntentIntegrator */ public void initializeFromIntent(Intent intent) { // Scan the formats the intent requested, and return the result to the calling activity. Set<BarcodeFormat> decodeFormats = DecodeFormatManager.parseDecodeFormats(intent); Map<DecodeHintType, Object> decodeHints = DecodeHintManager.parseDecodeHints(intent); CameraSettings settings = new CameraSettings(); if (intent.hasExtra(Intents.Scan.CAMERA_ID)) { int cameraId = intent.getIntExtra(Intents.Scan.CAMERA_ID, -1); if (cameraId >= 0) { settings.setRequestedCameraId(cameraId); } } // Check to see if the scan should be inverted. boolean inverted = intent.getBooleanExtra(Intents.Scan.INVERTED_SCAN, false); String characterSet = intent.getStringExtra(Intents.Scan.CHARACTER_SET); MultiFormatReader reader = new MultiFormatReader(); reader.setHints(decodeHints); barcodeView.setCameraSettings(settings); barcodeView.setDecoderFactory(new DefaultDecoderFactory(decodeFormats, decodeHints, characterSet, inverted)); }
Example 4
Project: letv File: KVUtils.java View Source Code | 7 votes |
public static Bundle put(Bundle to, Intent from, String key) { if (!(to == null || from == null || TextUtils.empty(key) || !from.hasExtra(key))) { Object value = from.getExtras().get(key); if (value instanceof Boolean) { to.putBoolean(key, ((Boolean) value).booleanValue()); } else if (value instanceof Byte) { to.putByte(key, ((Byte) value).byteValue()); } else if (value instanceof Character) { to.putChar(key, ((Character) value).charValue()); } else if (value instanceof Short) { to.putShort(key, ((Short) value).shortValue()); } else if (value instanceof Integer) { to.putInt(key, ((Integer) value).intValue()); } else if (value instanceof Long) { to.putLong(key, ((Long) value).longValue()); } else if (value instanceof Float) { to.putFloat(key, ((Float) value).floatValue()); } else if (value instanceof Double) { to.putDouble(key, ((Double) value).doubleValue()); } else if (value instanceof String) { to.putString(key, (String) value); } } return to; }
Example 5
Project: PeSanKita-android File: GcmBroadcastReceiver.java View Source Code | 7 votes |
@Override public void onReceive(Context context, Intent intent) { GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(context); String messageType = gcm.getMessageType(intent); if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { Log.w(TAG, "GCM message..."); if (!TextSecurePreferences.isPushRegistered(context)) { Log.w(TAG, "Not push registered!"); return; } String messageData = intent.getStringExtra("message"); String receiptData = intent.getStringExtra("receipt"); if (!TextUtils.isEmpty(messageData)) handleReceivedMessage(context, messageData); else if (!TextUtils.isEmpty(receiptData)) handleReceivedMessage(context, receiptData); else if (intent.hasExtra("notification")) handleReceivedNotification(context); } }
Example 6
Project: GravityBox File: ModPower.java View Source Code | 7 votes |
@Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equals(GravityBoxSettings.ACTION_PREF_POWER_CHANGED)) { if (intent.hasExtra(GravityBoxSettings.EXTRA_POWER_PROXIMITY_WAKE)) { toggleWakeUpWithProximityFeature(intent.getBooleanExtra( GravityBoxSettings.EXTRA_POWER_PROXIMITY_WAKE, false)); } if (intent.hasExtra(GravityBoxSettings.EXTRA_POWER_PROXIMITY_WAKE_IGNORE_CALL)) { mIgnoreIncomingCall = intent.getBooleanExtra( GravityBoxSettings.EXTRA_POWER_PROXIMITY_WAKE_IGNORE_CALL, false); } } else if (intent.getAction().equals(GravityBoxSettings.ACTION_PREF_BATTERY_SOUND_CHANGED) && intent.getIntExtra(GravityBoxSettings.EXTRA_BATTERY_SOUND_TYPE, -1) == BatteryInfoManager.SOUND_WIRELESS) { updateIsWirelessChargingSoundCustom(intent.getStringExtra( GravityBoxSettings.EXTRA_BATTERY_SOUND_URI)); } }
Example 7
Project: GravityBox File: QuickAppTile.java View Source Code | 7 votes |
@Override public void onBroadcastReceived(Context context, Intent intent) { super.onBroadcastReceived(context, intent); if (DEBUG) log(getKey() + ": onBroadcastReceived: " + intent.toString()); if (intent.getAction().equals(ACTION_PREF_QUICKAPP_CHANGED)) { if (intent.hasExtra(GravityBoxSettings.EXTRA_QUICKAPP_DEFAULT)) { updateMainApp(intent.getStringExtra(GravityBoxSettings.EXTRA_QUICKAPP_DEFAULT)); } if (intent.hasExtra(GravityBoxSettings.EXTRA_QUICKAPP_SLOT1)) { updateSubApp(0, intent.getStringExtra(GravityBoxSettings.EXTRA_QUICKAPP_SLOT1)); } if (intent.hasExtra(GravityBoxSettings.EXTRA_QUICKAPP_SLOT2)) { updateSubApp(1, intent.getStringExtra(GravityBoxSettings.EXTRA_QUICKAPP_SLOT2)); } if (intent.hasExtra(GravityBoxSettings.EXTRA_QUICKAPP_SLOT3)) { updateSubApp(2, intent.getStringExtra(GravityBoxSettings.EXTRA_QUICKAPP_SLOT3)); } if (intent.hasExtra(GravityBoxSettings.EXTRA_QUICKAPP_SLOT4)) { updateSubApp(3, intent.getStringExtra(GravityBoxSettings.EXTRA_QUICKAPP_SLOT4)); } } }
Example 8
Project: GravityBox File: QuickRecordTile.java View Source Code | 6 votes |
@Override public void onBroadcastReceived(Context context, Intent intent) { super.onBroadcastReceived(context, intent); if (intent.getAction().equals(GravityBoxSettings.ACTION_PREF_QUICKSETTINGS_CHANGED)) { if (intent.hasExtra(GravityBoxSettings.EXTRA_QR_QUALITY)) { mAudioQuality = intent.getIntExtra(GravityBoxSettings.EXTRA_QR_QUALITY, RecordingService.DEFAULT_SAMPLING_RATE); } if (intent.hasExtra(GravityBoxSettings.EXTRA_QR_AUTOSTOP)) { mAutoStopDelay = intent.getIntExtra(GravityBoxSettings.EXTRA_QR_AUTOSTOP, 1) * 3600000; } } }
Example 9
Project: gamesboard File: GameListActivity.java View Source Code | 6 votes |
private void showDialogIf(Intent intent) { if (intent.hasExtra("id")) { id = intent.getExtras().getString("id"); intent.removeExtra("id"); Bundle args = new Bundle(); args.putString("id", id); JoinGameDialogFragment fragment = new JoinGameDialogFragment(); fragment.setArguments(args); fragment.show(getSupportFragmentManager(), "dialog"); } }
Example 10
Project: android-apkbox File: Proxy404Service.java View Source Code | 6 votes |
@Override public void onStart(Intent intent, int startId) { if (DEBUG_LIFECYCLE) ApkLogger.get().debug(TAG + " - onStart", null); super.onStart(intent, startId); if (intent != null && intent.hasExtra(ApkConstant.EXTRA_APK_TARGET_INTENT)) { Intent target = intent.getParcelableExtra(ApkConstant.EXTRA_APK_TARGET_INTENT); HookService_Manager.onStartService(this, target, startId); } }
Example 11
Project: localcloud_fe File: CoreAndroid.java View Source Code | 6 votes |
/** * Listen for telephony events: RINGING, OFFHOOK and IDLE * Send these events to all plugins using * CordovaActivity.onMessage("telephone", "ringing" | "offhook" | "idle") */ private void initTelephonyReceiver() { IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED); //final CordovaInterface mycordova = this.cordova; this.telephonyReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { // If state has changed if ((intent != null) && intent.getAction().equals(TelephonyManager.ACTION_PHONE_STATE_CHANGED)) { if (intent.hasExtra(TelephonyManager.EXTRA_STATE)) { String extraData = intent.getStringExtra(TelephonyManager.EXTRA_STATE); if (extraData.equals(TelephonyManager.EXTRA_STATE_RINGING)) { LOG.i(TAG, "Telephone RINGING"); webView.getPluginManager().postMessage("telephone", "ringing"); } else if (extraData.equals(TelephonyManager.EXTRA_STATE_OFFHOOK)) { LOG.i(TAG, "Telephone OFFHOOK"); webView.getPluginManager().postMessage("telephone", "offhook"); } else if (extraData.equals(TelephonyManager.EXTRA_STATE_IDLE)) { LOG.i(TAG, "Telephone IDLE"); webView.getPluginManager().postMessage("telephone", "idle"); } } } } }; // Register the receiver webView.getContext().registerReceiver(this.telephonyReceiver, intentFilter); }
Example 12
Project: SOS-The-Healthcare-Companion File: HelloActivity.java View Source Code | 6 votes |
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REQUEST_CONTACT && resultCode == Activity.RESULT_OK && data != null && (data.hasExtra(ContactPickerActivity.RESULT_GROUP_DATA) || data.hasExtra(ContactPickerActivity.RESULT_CONTACT_DATA))) { List<Contact> mContacts = (List<Contact>) data.getSerializableExtra(ContactPickerActivity.RESULT_CONTACT_DATA); populateContactList(mContacts); } }
Example 13
Project: GravityBox File: StatusBarIconManager.java View Source Code | 6 votes |
@Override public void onBroadcastReceived(Context context, Intent intent) { if (intent.getAction().equals(GravityBoxSettings.ACTION_PREF_STATUSBAR_COLOR_CHANGED)) { if (intent.hasExtra(GravityBoxSettings.EXTRA_SB_ICON_COLOR)) { setIconColor(intent.getIntExtra( GravityBoxSettings.EXTRA_SB_ICON_COLOR, getDefaultIconColor())); } else if (intent.hasExtra(GravityBoxSettings.EXTRA_SB_ICON_STYLE)) { setIconStyle(intent.getIntExtra(GravityBoxSettings.EXTRA_SB_ICON_STYLE, 0)); } else if (intent.hasExtra(GravityBoxSettings.EXTRA_SB_ICON_COLOR_SECONDARY)) { setIconColor(1, intent.getIntExtra( GravityBoxSettings.EXTRA_SB_ICON_COLOR_SECONDARY, getDefaultIconColor())); } else if (intent.hasExtra(GravityBoxSettings.EXTRA_SB_DATA_ACTIVITY_COLOR)) { setDataActivityColor(intent.getIntExtra( GravityBoxSettings.EXTRA_SB_DATA_ACTIVITY_COLOR, mColorInfo.defaultDataActivityColor)); } else if (intent.hasExtra(GravityBoxSettings.EXTRA_SB_DATA_ACTIVITY_COLOR_SECONDARY)) { setDataActivityColor(1, intent.getIntExtra( GravityBoxSettings.EXTRA_SB_DATA_ACTIVITY_COLOR_SECONDARY, mColorInfo.defaultDataActivityColor)); } else if (intent.hasExtra(GravityBoxSettings.EXTRA_SB_ICON_COLOR_ENABLE)) { setColoringEnabled(intent.getBooleanExtra( GravityBoxSettings.EXTRA_SB_ICON_COLOR_ENABLE, false)); if (DEBUG) log("Icon colors master switch set to: " + isColoringEnabled()); } else if (intent.hasExtra(GravityBoxSettings.EXTRA_SB_SIGNAL_COLOR_MODE)) { setSignalIconMode(intent.getIntExtra( GravityBoxSettings.EXTRA_SB_SIGNAL_COLOR_MODE, StatusBarIconManager.SI_MODE_STOCK)); } } }
Example 14
Project: android-apkbox File: HookActivity_Intent.java View Source Code | 6 votes |
public static Intent modify(Activity target, Intent intent) { if (!intent.hasExtra(ApkConstant.EXTRA_APK_PATH) && target.getIntent().hasExtra(ApkConstant.EXTRA_APK_PATH)) { Bundle extras = intent.getExtras(); if (extras != null) { intent.replaceExtras(new Bundle()); String extras_id = ApkExtras.putExtras(extras); intent.putExtra(ApkConstant.EXTRA_APK_EXTRAS, extras_id); } String apkPath = target.getIntent().getStringExtra(ApkConstant.EXTRA_APK_PATH); intent.putExtra(ApkConstant.EXTRA_APK_PATH, apkPath); // launch mode if (intent.getComponent() != null) { try { ActivityInfo activityInfo = ApkLoaded.get(target, apkPath).getActivityInfo(intent.getComponent().getClassName()); String launchModeStr = HookActivity_Component.STANDARD; int launchMode = activityInfo.launchMode; if (launchMode == ActivityInfo.LAUNCH_SINGLE_INSTANCE) { launchModeStr = HookActivity_Component.SINGLE_INSTANCE; } else if (launchMode == ActivityInfo.LAUNCH_SINGLE_TASK) { launchModeStr = HookActivity_Component.SINGLE_TASK; } else if (launchMode == ActivityInfo.LAUNCH_SINGLE_TOP) { launchModeStr = HookActivity_Component.SINGLE_TOP; } intent.putExtra(ApkConstant.EXTRA_APK_LAUNCH_MODE, launchModeStr); } catch (Exception e) { } } } return HookActivity_Component.modify(intent); }
Example 15
Project: TraiNFCUI File: Tap.java View Source Code | 6 votes |
@Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); if (intent.hasExtra(NfcAdapter.EXTRA_TAG)) { Toast.makeText(this, "NfcIntent!", Toast.LENGTH_SHORT).show(); Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG); NdefMessage ndefMessage = createNdefMessage("My string content!"); writeNdefMessage(tag, ndefMessage); } }
Example 16
Project: boohee_v5.6 File: MediaButtonReceiver.java View Source Code | 6 votes |
public static KeyEvent handleIntent(MediaSessionCompat mediaSessionCompat, Intent intent) { if (mediaSessionCompat == null || intent == null || !"android.intent.action.MEDIA_BUTTON".equals(intent.getAction()) || !intent.hasExtra("android.intent.extra.KEY_EVENT")) { return null; } KeyEvent ke = (KeyEvent) intent.getParcelableExtra("android.intent.extra.KEY_EVENT"); mediaSessionCompat.getController().dispatchMediaButtonEvent(ke); return ke; }
Example 17
Project: Open-Quran-Radio File: PlayerService.java View Source Code | 5 votes |
@Override //@AddTrace(name = "onStartCommand", enabled = true/*Optional*/) public int onStartCommand(Intent intent, int flags, int startId) { // checking for empty intent if (intent == null) { LogHelper.v(LOG_TAG, "Null-Intent received. Stopping self."); stopForeground(true); // Remove notification stopSelf(); } // ACTION PLAY else if (intent.getAction().equals(TransistorKeys.ACTION_PLAY)) { LogHelper.v(LOG_TAG, "Service received command: PLAY"); // get URL of station from intent if (intent.hasExtra(TransistorKeys.EXTRA_STATION)) { mStation = intent.getParcelableExtra(TransistorKeys.EXTRA_STATION); mStationID_Position = intent.getIntExtra(TransistorKeys.EXTRA_STATION_Position_ID, 0); mStreamUri = mStation.getStreamUri().toString(); } // update controller - start playback mController.getTransportControls().play(); } // ACTION STOP else if (intent.getAction().equals(TransistorKeys.ACTION_STOP)) { LogHelper.v(LOG_TAG, "Service received command: STOP"); // update controller - pause playback mController.getTransportControls().pause(); } // ACTION DISMISS else if (intent.getAction().equals(TransistorKeys.ACTION_DISMISS)) { LogHelper.v(LOG_TAG, "Service received command: DISMISS"); // update controller - stop playback mController.getTransportControls().stop(); } // listen for media button MediaButtonReceiver.handleIntent(mSession, intent); // default return value for media playback return START_STICKY; }
Example 18
Project: Habitizer File: EditProfileActivity.java View Source Code | 5 votes |
/** * Called when activity starts, used for displaying/editing profile * @param savedInstanceState */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.profile_tab); Intent intent = getIntent(); fromSignup = intent.getBooleanExtra("fromSignup", false); if (!(fromSignup || intent.hasExtra(SocialMultiAdapter.SOCIAL2ACCOUNT))){ DummyMainActivity.initTabs(DummyMainActivity.VIEW_EDIT_PROFILE, EditProfileActivity.this, intent);} nmText = (TextView) findViewById(R.id.nmText); btText = (TextView) findViewById(R.id.btText); gdText = (TextView) findViewById(R.id.gdText); imageButton = (ImageButton) findViewById(R.id.image_btn); imageV = (ImageView) findViewById(R.id.imageView); nameText = (EditText) findViewById(R.id.usr_name); birthdayText = (TextView) findViewById(R.id.birth_date); genderSpn = (Spinner) findViewById(R.id.gender_spn); confirmButton = (Button) findViewById(R.id.confirm_btn); adapter = ArrayAdapter.createFromResource(this, R.array.gender_array, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_item); genderSpn.setAdapter(adapter); nameDisplay = (TextView) findViewById(R.id.name_dis); birthDisplay = (TextView) findViewById(R.id.birth_dis); genderDisplay = (TextView) findViewById(R.id.gender_dis); follow = (Button) findViewById(R.id.follow_btn); viewHabit = (Button) findViewById(R.id.viewHabits_btn); editButton = (Button) findViewById(R.id.edit_btn); logoutButton = (Button) findViewById(R.id.logout_btn); nameLayout = (LinearLayout) findViewById(R.id.lay_name); birthLayout = (LinearLayout) findViewById(R.id.lay_birth); genderLayout = (LinearLayout) findViewById(R.id.lay_gender); followLayout = (LinearLayout) findViewById(R.id.lay_follow); if (fromSignup){ onEditEvent(); } else{ onDisplayEvent(); } }
Example 19
Project: ActivityBuilder File: RefManager.java View Source Code | 5 votes |
public static boolean hasRefMap(Intent intent) { return intent.hasExtra(KEY_OF_MAP); }
Example 20
Project: TaBeTa File: GameActivity.java View Source Code | 5 votes |
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); try { if (requestCode == DeveloperInterface.TAPSELL_DIRECT_ADD_REQUEST_CODE) { if (data.hasExtra(DeveloperInterface.TAPSELL_DIRECT_AWARD_RESPONSE)) { // The video Has been Watched Completely int CoinCount = information.getInt(COIN_TAG, 0) + Constants.VideoAward; Editor et = information.edit(); //Server.SubmitCoin(CoinCount, android_id, et); et.putInt(COIN_TAG, CoinCount); String StartTime = EndTime; SimpleDateFormat sdf = new SimpleDateFormat( "dd/M/yyyy HH:mm:ss", java.util.Locale.getDefault()); Calendar c = Calendar.getInstance(); c.setTime(sdf.parse(EndTime)); c.add(Calendar.HOUR, Constants.VideoWaiting); // number of // Hours to // add EndTime = sdf.format(c.getTime()); // dt is now the new date et.putString(EndTimeTag, EndTime); et.commit(); // Now Disable The Button For 6 Hours... Date StartDate = StringToDate(StartTime); Date EndDate = StringToDate(EndTime); Long diffrence = EndDate.getTime() - StartDate.getTime(); StartTimer(diffrence); UpdateUI(); // HintPanel.show(); } else { Toast.makeText(getApplicationContext(), "مراحل مشاهده ی ویدئو را تکمیل نکردید!", Toast.LENGTH_SHORT).show(); } } } catch (Exception e) { e.printStackTrace(); } }