Android Intent - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android Intent class.

This code example shows how to use the following methods:putExtra
        } 
        catch (Exception e) {
            Log.e(LOG_TAG, String.format("startSpeechRecognitionActivity exception: %s", e.toString()));
        } 
 
        Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
        intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
        intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.ENGLISH);
        if (maxMatches > 0)
            intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, maxMatches);
        if (!prompt.equals(""))
            intent.putExtra(RecognizerIntent.EXTRA_PROMPT, prompt);
        cordova.startActivityForResult(this, intent, reqCode);
    } 
 
    /** 
     * Handle the results from the recognition activity. 
     */ 
    @Override 
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
10
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:addFlags, putExtra, setClass, setClipData
    @SuppressLint("NewApi") 
    public static Intent createChooser(Intent target, CharSequence title) {
        if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
            return Intent.createChooser(target, title);
        } 
        Intent intent = new Intent();
        intent.setClass(Application.getLastInstance(), ChooserActivity.class);
        intent.putExtra(Intent.EXTRA_INTENT, target);
        if (title != null) {
            intent.putExtra(Intent.EXTRA_TITLE, title);
        } 
        int permFlags = target.getFlags()
                & (Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
        if (permFlags != 0 && VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
            ClipData targetClipData = target.getClipData();
            if (targetClipData == null && target.getData() != null) {
                ClipData.Item item = new ClipData.Item(target.getData());
                String[] mimeTypes;
                if (target.getType() != null) {
                    mimeTypes = new String[]{

9
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:putExtra
    protected Object onGetDefaultValue(TypedArray a, int index) {
        return a.getString(index);
    } 
 
    protected void onPrepareRingtonePickerIntent(Intent ringtonePickerIntent) {
        ringtonePickerIntent.putExtra(
                RingtoneManager.EXTRA_RINGTONE_EXISTING_URI,
                onRestoreRingtone()); 
        ringtonePickerIntent.putExtra(
                RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, mShowDefault);
        if (mShowDefault) {
            ringtonePickerIntent.putExtra(
                    RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI,
                    RingtoneManager.getDefaultUri(getRingtoneType()));
        } 
        ringtonePickerIntent.putExtra(
                RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, mShowSilent);
        ringtonePickerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE,
                mRingtoneType);
        ringtonePickerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE,

9
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getBooleanExtra, getIntExtra, getParcelableExtra
    public _RingtonePickerDialog create() { 
        if (dialog != null) {
            return this;
        } 
        handler = new Handler();
        hasDefaultItem = intent.getBooleanExtra(
                RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
        uriForDefaultItem = intent
                .getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI);
        if (uriForDefaultItem == null) {
            uriForDefaultItem = Settings.System.DEFAULT_RINGTONE_URI;
        } 
        hasSilentItem = intent.getBooleanExtra(
                RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, true);
        ringtoneManager = new RingtoneManager(context);
        final boolean includeDrm = intent.getBooleanExtra(
                RingtoneManager.EXTRA_RINGTONE_INCLUDE_DRM, true);
        ringtoneManager.setIncludeDrm(includeDrm);
        int types = intent.getIntExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, -1);
        if (types != -1) {

9
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:putExtra, setAction
        signer.update(requiredPrevious.trim().getBytes());
        return signer.verify(Base64.decode(signature.getBytes(), Base64.DEFAULT));
    } 
 
    private void sendIntent(String contentPath, String version, String required, String sig) {
        Intent i = new Intent();
        i.setAction("android.intent.action.UPDATE_PINS");
        i.putExtra(EXTRA_CONTENT_PATH, contentPath);
        i.putExtra(EXTRA_VERSION_NUMBER, version);
        i.putExtra(EXTRA_REQUIRED_HASH, required);
        i.putExtra(EXTRA_SIGNATURE, sig);
        mContext.sendBroadcast(i);
    } 
 
    private String runTest(String cert, String content, String version, String required, String sig)
                           throws Exception { 
        Log.e(TAG, "started test");
        overrideCert(cert);
        String contentPath = makeTemporaryContentFile(content);
        sendIntent(contentPath, version, required, sig);
9
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getAction, getBundleExtra, getParcelableExtra, getStringExtra
    super("InterpreterService"); 
  } 
   
  @Override 
  protected void onHandleIntent(Intent intent) {
    String action=intent.getAction();
    I_Interpreter interpreter=interpreters.get(action);  
     
    if (interpreter==null) {
      try { 
        interpreter=(I_Interpreter)Class.forName(action).newInstance();
        interpreters.put(action, interpreter);
      } 
      catch (Throwable t) {
        Log.e("InterpreterService", "Error creating interpreter", t);
      } 
    } 
     
    if (interpreter==null) {
      failure(intent, "Could not create interpreter: "+intent.getAction());

9
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:putExtra
        } 
        catch (Exception e) {
            Log.e(LOG_TAG, String.format("startSpeechRecognitionActivity exception: %s", e.toString()));
        } 
 
        Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
        intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
        intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.ENGLISH);
        if (maxMatches > 0)
            intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, maxMatches);
        if (!prompt.equals(""))
            intent.putExtra(RecognizerIntent.EXTRA_PROMPT, prompt);
        cordova.startActivityForResult(this, intent, reqCode);
    } 
 
    /** 
     * Handle the results from the recognition activity. 
     */ 
    @Override 
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
9
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getExtras, putExtra, removeExtra
    context.startActivity(intent);
  } 
 
  @Override 
  public void onReceive(Context context, Intent intent) {
    String phoneNumber        = intent.getExtras().getString(INTENT_PHONE_NUMBER);
    NumberFilter numberFilter = NumberFilter.deserializeFromFile(context);
 
    if( phoneNumber == null )
      return; 
 
    if (phoneNumber.endsWith(IGNORE_SUFFIX)) {
      phoneNumber = phoneNumber.substring(0, phoneNumber.length() - IGNORE_SUFFIX.length());
      intent.removeExtra(INTENT_PHONE_NUMBER);
      intent.removeExtra("android.phone.extra.ORIGINAL_URI");
 
      intent.putExtra(INTENT_PHONE_NUMBER, phoneNumber);
      intent.putExtra("android.phone.extra.ORIGINAL_URI", "tel:" + Uri.encode(phoneNumber));
 
      setResultData(phoneNumber);

10
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getComponent, setComponent
    assertThat(rpm.resolveService(i, 0)).isNull();
  } 
 
  @Test 
  public void queryActivityIcons__Match() throws Exception { 
    Intent i = new Intent();
    i.setComponent(new ComponentName(TEST_PACKAGE_NAME, ""));
    Drawable d = new BitmapDrawable();
 
    rpm.addActivityIcon(i, d);
 
    assertThat(rpm.getActivityIcon(i)).isSameAs(d);
    assertThat(rpm.getActivityIcon(i.getComponent())).isSameAs(d);
  } 
 
  @Test 
  public void hasSystemFeature() throws Exception { 
    // uninitialized 
    assertThat(rpm.hasSystemFeature(PackageManager.FEATURE_CAMERA)).isFalse();
 
9
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:addFlags, setClassName
	{ 
		super.onStart(); 
		Looper.prepare();
 
		Log.d(TAG, "Starting package/activity: " + getTargetContext().getPackageName() + "/" + activityClassName);
		Intent intent = new Intent();
		intent.setClassName(getTargetContext(), activityClassName);
		intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		Activity activity = startActivitySync(intent);
		if (activity instanceof InstrumentedActivity)
		{ 
			((InstrumentedActivity)activity).setInstrumentation(this);
		} 
		waitForIdleSync();
	} 
 
	@Override 
	public boolean onException(Object obj, Throwable e)
	{ 
		// log, but ignore exceptions 
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java

Related Android Intent Questions & Answers:

Other Android Intent Examples

15:	
16:	  public void onClick(View view) {
17:	    Intent intent = new Intent(WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER);
18:	    intent.putExtra(WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT,
19:	        new ComponentName(this, MyWallpaperService.class));
-
15:	
16:	  public void onClick(View view) {
17:	    Intent intent = new Intent(WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER);
18:	    intent.putExtra(WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT,
19:	        new ComponentName(this, MyWallpaperService.class));

Read More

26:	
27:	  public void pickImage(View View) {
28:	    Intent intent = new Intent();
29:	    intent.setType("image/*");
30:	    intent.setAction(Intent.ACTION_GET_CONTENT);
-
26:	
27:	  public void pickImage(View View) {
28:	    Intent intent = new Intent();
29:	    intent.setType("image/*");
30:	    intent.setAction(Intent.ACTION_GET_CONTENT);
-
34:	
35:	  @Override
36:	  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
37:	    InputStream stream = null;
38:	    if (requestCode == REQUEST_CODE && resultCode == Activity.RESULT_OK)

Read More

1:	IntentFilter filter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
2:	
3:	/ Intent is sticky so using null as receiver works fine
4:	// return value contains the status
5:	Intent batteryStatus = this.registerReceiver(null, filter);
-
3:	/ Intent is sticky so using null as receiver works fine
4:	// return value contains the status
5:	Intent batteryStatus = this.registerReceiver(null, filter);
6:	
7:	// Are we charging / charged?

Read More

2:		 */
3:		private void recordVideo() {
4:			Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
5:	
6:			fileUri = getOutputMediaFileUri(MEDIA_TYPE_VIDEO);
-
2:		 */
3:		private void recordVideo() {
4:			Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
5:	
6:			fileUri = getOutputMediaFileUri(MEDIA_TYPE_VIDEO);

Read More

2:		 */
3:		private void captureImage() {
4:			Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
5:	
6:			fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE);
-
2:		 */
3:		private void captureImage() {
4:			Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
5:	
6:			fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE);

Read More

2:		 * */
3:		@Override
4:		protected void onActivityResult(int requestCode, int resultCode, Intent data) {
5:			// if the result is capturing Image
6:			if (requestCode == CAMERA_CAPTURE_IMAGE_REQUEST_CODE) {

Read More

2:	    ...
3:	    // Triggers password change screen in Settings.
4:	    Intent intent =
5:	        new Intent(DevicePolicyManager.ACTION_SET_NEW_PASSWORD);
6:	    startActivity(intent);
-
3:	    // Triggers password change screen in Settings.
4:	    Intent intent =
5:	        new Intent(DevicePolicyManager.ACTION_SET_NEW_PASSWORD);
6:	    startActivity(intent);
7:	}

Read More

1:	if (!mPolicy.isAdminActive()) {
2:	
3:	    Intent activateDeviceAdminIntent =
4:	        new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
5:	
-
2:	
3:	    Intent activateDeviceAdminIntent =
4:	        new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
5:	
6:	    activateDeviceAdminIntent.putExtra(

Read More

5:	    // Create an Intent that describes the requirements to fulfill, to be included
6:	    // in our menu. The offering app must include a category value of Intent.CATEGORY_ALTERNATIVE.
7:	    Intent intent = new Intent(null, dataUri);
8:	    intent.addCategory(Intent.CATEGORY_ALTERNATIVE);
9:	
-
5:	    // Create an Intent that describes the requirements to fulfill, to be included
6:	    // in our menu. The offering app must include a category value of Intent.CATEGORY_ALTERNATIVE.
7:	    Intent intent = new Intent(null, dataUri);
8:	    intent.addCategory(Intent.CATEGORY_ALTERNATIVE);
9:

Read More

See Code Examples for Android Intent Methods: