Intent setData - top ranked examples from Open Source projects

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

This code example shows how to use the following methods:setData
 
        return Utils.deviceCanHandleIntent(context, telIntent);
    } 
 
    public static boolean isSmsAvailable(Context context) {
        Intent smsIntent = new Intent(Intent.ACTION_VIEW);
        smsIntent.setData(Uri.parse("sms:"));
 
        return Utils.deviceCanHandleIntent(context, smsIntent);
    } 
 
    public static boolean isStorePictureSupported(Context context) {
        return MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
                && context.checkCallingOrSelfPermission(WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED;
    } 
 
    public static boolean isCalendarAvailable(Context context) {
        Intent calendarIntent = new Intent(Intent.ACTION_INSERT).setType(ANDROID_CALENDAR_CONTENT_TYPE);
 
        return VersionCode.currentApiLevel().isAtLeast(VersionCode.ICE_CREAM_SANDWICH) 
7
CodeRank
This code example shows how to use the following methods:addFlags, setClass, setData
            } 
        } 
    } 
     
    void grantUriPermissionFail(Uri uri, int mode, boolean service) {
        Intent grantIntent = new Intent();
        grantIntent.setData(uri);
        grantIntent.addFlags(mode);
        grantIntent.setClass(getContext(),
                service ? ReceiveUriService.class : ReceiveUriActivity.class);
        Intent intent = new Intent();
        intent.setComponent(GRANT_URI_PERM_COMP);
        intent.putExtra("intent", grantIntent);
        intent.putExtra("service", service);
        GrantResultReceiver receiver = new GrantResultReceiver();
        getContext().sendOrderedBroadcast(intent, null, receiver, null, 0, null, null);
        receiver.assertFailure("Able to grant URI permission to " + uri + " when should not");
    } 
 
    void doTestGrantUriPermissionFail(Uri uri) {
7
CodeRank
This code example shows how to use the following methods:setData
            } 
        } 
    } 
 
    private Intent tryBugReporter(Uri bugreportUri) {
        final Intent intent = new Intent(SEND_BUG_INTENT_ACTION);
        intent.setData(bugreportUri);
        final IPackageManager mPm = IPackageManager.Stub.asInterface(
                ServiceManager.getService("package")); 
        if (mPm != null) {
            final List<ResolveInfo> results;
            try { 
                results = mPm.queryIntentActivities(intent, null, 0);
            } catch (RemoteException e) {
                return null; 
            } 
            if (results != null && results.size() > 0) {
                final ResolveInfo info = results.get(0);
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                intent.setClassName(info.activityInfo.applicationInfo.packageName,
6
CodeRank
This code example shows how to use the following methods:setData
package com.michaelpardo.android.util; 
 
import android.content.Context; 
import android.content.Intent; 
import android.content.pm.PackageManager; 
import android.net.Uri; 
import android.text.TextUtils; 
 
public class IntentUtils { 
	public static void startWebActivity(Context context, String url) {
		final Intent intent = new Intent(Intent.ACTION_VIEW);
		intent.setData(Uri.parse(url));
		context.startActivity(intent);
	} 
 
	public static void startEmailActivity(Context context, int toResId, int subjectResId, int bodyResId) {
		startEmailActivity(context, context.getString(toResId), context.getString(subjectResId),
				context.getString(bodyResId));
	} 
 

6
CodeRank
This code example shows how to use the following methods:setData
 
	@Override 
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
 
		Intent i = new Intent(this, ImportSudokuActivity.class);
		i.setData(getIntent().getData());
		startActivity(i);
		finish();
	} 
 
} 
6
CodeRank
This code example shows how to use the following methods:addFlags, putExtra, setComponent, setData
        String query = cursor.getSuggestionQuery();
        String userQuery = cursor.getUserQuery();
        String extraData = cursor.getSuggestionIntentExtraData();
 
        // Now build the Intent 
        Intent intent = new Intent(action);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        // We need CLEAR_TOP to avoid reusing an old task that has other activities 
        // on top of the one we want. 
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        if (data != null) {
            intent.setData(Uri.parse(data));
        } 
        intent.putExtra(SearchManager.USER_QUERY, userQuery);
        if (query != null) {
            intent.putExtra(SearchManager.QUERY, query);
        } 
        if (extraData != null) {
            intent.putExtra(SearchManager.EXTRA_DATA_KEY, extraData);
        } 

6
CodeRank
This code example shows how to use the following methods:getData, setData
    } 
 
    @Override 
    protected Uri resolveIntent() {
        Intent intent = getIntent();
        intent.setData(Uri.parse("content://icc/fdn"));
        return intent.getData();
    } 
 
    @Override 
    public boolean onCreateOptionsMenu(Menu menu) {
        super.onCreateOptionsMenu(menu);
 
        Resources r = getResources();
 
        // Added the icons to the context menu 
        menu.add(0, MENU_ADD, 0, r.getString(R.string.menu_add))
                .setIcon(android.R.drawable.ic_menu_add);
        menu.add(0, MENU_EDIT, 0, r.getString(R.string.menu_edit))
                .setIcon(android.R.drawable.ic_menu_edit);
6
CodeRank
This code example shows how to use the following methods:startActivity, setData, setFlags
 
 
public class Launcher extends NativeActivity {
 
	public void goToWebsite(final String url){
		Intent intent = new Intent(Intent.ACTION_VIEW);
		intent.setData(Uri.parse(url));
		intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		getApplicationContext().startActivity(intent);
	} 
} 
 
8
CodeRank
This code example shows how to use the following methods:setData
	protected void onDestroy() { 
		super.onDestroy(); 
	} 
 
	public void quickTour(View view) {
		Intent i = new Intent(Intent.ACTION_VIEW);
		i.setData(Uri.parse("http://jadn.com/cc/walk/"));
		startActivity(i);
	} 
 
	public void qanda(View view) {
		Intent i = new Intent(Intent.ACTION_VIEW);
		i.setData(Uri.parse("http://jadn.com/cc/QandA/"));
		startActivity(i);
	} 
 
	public void email(View view) {
		Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
		emailIntent.setType("plain/text");
		emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { "carcast-devs@googlegroups.com" });
6
CodeRank
This code example shows how to use the following methods:setAction, setData
		{ 
			/* 
			 * notify the media to scan  
			 */ 
			Uri mUri = Uri.fromFile(mfile);
			Intent mIntent = new Intent();
			mIntent.setData(mUri);
			mIntent.setAction(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
			mContext.sendBroadcast(mIntent);
		} 
	} 
	 
	public void notifyMediaDelete(String file)
	{ 
		final int ID_AUDIO_COLUMN_INDEX = 0;
        final int PATH_AUDIO_COLUMN_INDEX = 1;
		String[] PROJECTION = new String[] {
								Audio.Media._ID,
								Audio.Media.DATA,
								}; 
6
CodeRank

Related Intent setData Questions & Answers:

setData Method Overview
Set the data this intent is operating on.
See Code Examples for other Android Intent Methods: