Java Code Examples for android.content.Intent.setData()

The following are Jave code examples for showing how to use setData() 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: MyRepository   File: DownloadService.java   View Source Code Vote up 9 votes
private void installAPK(Uri apk, Context context) {
    if (Build.VERSION.SDK_INT < 23) {
        Intent intents = new Intent();
        intents.setAction("android.intent.action.VIEW");
        intents.addCategory("android.intent.category.DEFAULT");
        intents.setType("application/vnd.android.package-archive");
        intents.setData(apk);
        intents.setDataAndType(apk, "application/vnd.android.package-archive");
        intents.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intents);
    } else {
        Log.e("6.0系统apk路径",apk.getPath());
        if (destinationFile.exists()) {
            openFile(destinationFile, context);
        }
    }
}
 
Example 2
Project: stynico   File: z.java   View Source Code Vote up 6 votes
public boolean ajoinQQGroupdata(String key)
    {
		Intent intent = new Intent();
		intent.setData(Uri.parse("mqqopensdkapi://bizAgent/qm/qr?url=http%3A%2F%2Fqm.qq.com%2Fcgi-bin%2Fqm%2Fqr%3Ffrom%3Dapp%26p%3Dandroid%26k%3D" + key));
// 此Flag可根据具体产品需要自定义,如设置,则在加群界面按返回,返回手Q主界面,不设置,按返回会返回到呼起产品界面    //intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
		try
		{
			startActivity(intent);
			return true;
		}
		catch (Exception e)
		{
// 未安装手Q或安装的版本不支持
			return false;
		}
    }
 
Example 3
Project: android-dev-challenge   File: MainActivity.java   View Source Code Vote up 6 votes
/**
 * Uses the URI scheme for showing a location found on a map in conjunction with
 * an implicit Intent. This super-handy Intent is detailed in the "Common Intents" page of
 * Android's developer site:
 *
 * @see "http://developer.android.com/guide/components/intents-common.html#Maps"
 * <p>
 * Protip: Hold Command on Mac or Control on Windows and click that link to automagically
 * open the Common Intents page
 */
private void openPreferredLocationInMap() {
    double[] coords = SunshinePreferences.getLocationCoordinates(this);
    String posLat = Double.toString(coords[0]);
    String posLong = Double.toString(coords[1]);
    Uri geoLocation = Uri.parse("geo:" + posLat + "," + posLong);

    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(geoLocation);

    if (intent.resolveActivity(getPackageManager()) != null) {
        startActivity(intent);
    } else {
        Log.d(TAG, "Couldn't call " + geoLocation.toString() + ", no receiving apps installed!");
    }
}
 
Example 4
Project: Espresso   File: AppWidgetProvider.java   View Source Code Vote up 6 votes
private RemoteViews updateWidgetListView(Context context, int id) {
    RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.launcher_list_widget);

    Intent intent = new Intent(context, AppWidgetService.class);
    intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, id);
    intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));

    remoteViews.setRemoteAdapter(R.id.listViewWidget, intent);
    remoteViews.setEmptyView(R.id.listViewWidget, R.id.emptyView);

    Intent tempIntent = new Intent(context, PackageDetailsActivity.class);
    tempIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    remoteViews.setPendingIntentTemplate(R.id.listViewWidget,
            PendingIntent.getActivity(context, 0, tempIntent, PendingIntent.FLAG_CANCEL_CURRENT));

    return remoteViews;
}
 
Example 5
Project: iosched-reader   File: ExploreIOActivity.java   View Source Code Vote up 5 votes
public void cardHeaderClicked(View viewClicked) {
    LOGD(TAG, "clicked: " + viewClicked + " " +
            ((viewClicked != null) ? viewClicked.getTag() : ""));
    View moreButton = viewClicked.findViewById(android.R.id.button1);
    Object tag = moreButton != null ? moreButton.getTag() : null;
    Intent intent = new Intent(getApplicationContext(), ExploreSessionsActivity.class);
    if (tag instanceof LiveStreamData) {
        intent.setData(ScheduleContract.Sessions.buildSessionsAfterUri(UIUtils.getCurrentTime(this)));
        intent.putExtra(ExploreSessionsActivity.EXTRA_SHOW_LIVE_STREAM_SESSIONS, true);
    } else if (tag instanceof ItemGroup) {
        intent.putExtra(ExploreSessionsActivity.EXTRA_FILTER_TAG, ((ItemGroup)tag).getId());
    }
    startActivity(intent);
}
 
Example 6
Project: Phoenix-for-VK   File: VideoPreviewFragment.java   View Source Code Vote up 5 votes
private void playWithCoub(Video video) {
    String outerLink = video.getExternalLink();

    Intent intent = new Intent();
    intent.setData(Uri.parse(outerLink));
    intent.setAction(Intent.ACTION_VIEW);
    intent.setComponent(new ComponentName("com.coub.android", "com.coub.android.ui.ViewCoubActivity"));
    startActivity(intent);
}
 
Example 7
Project: firefox-tv   File: Browsers.java   View Source Code Vote up 5 votes
private void findKnownBrowsers(PackageManager packageManager, Map<String, ActivityInfo> browsers, @NonNull Uri uri) {
    for (final KnownBrowser browser : KnownBrowser.values()) {
        if (browsers.containsKey(browser.packageName)) {
            continue;
        }

        // resolveActivity() can be slow if the package isn't installed (e.g. 200ms on an N6 with a bad WiFi connection).
        // Hence we query if the package is installed first, and only call resolveActivity for installed packages.
        // getPackageInfo() is fast regardless of a package being installed
        try {
            // We don't need the result, we only need to detect when the package doesn't exist
            packageManager.getPackageInfo(browser.packageName, 0);
        } catch (PackageManager.NameNotFoundException e) {
            continue;
        }

        final Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setData(uri);
        intent.setPackage(browser.packageName);

        final ResolveInfo info = packageManager.resolveActivity(intent, 0);
        if (info == null || info.activityInfo == null) {
            continue;
        }

        if (!info.activityInfo.exported) {
            continue;
        }

        browsers.put(info.activityInfo.packageName, info.activityInfo);
    }
}
 
Example 8
Project: MyFire   File: DialogPermissionUtil.java   View Source Code Vote up 5 votes
/**
 * 启动app设置授权界面
 * @param context
 */
public static void startSettingIntent(Context context) {
    Intent localIntent = new Intent();
    localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    if (Build.VERSION.SDK_INT >= 9) {
        localIntent.setAction("android.settings.APPLICATION_DETAILS_SETTINGS");
        localIntent.setData(Uri.fromParts("package", context.getPackageName(),null));
    } else if (Build.VERSION.SDK_INT <= 8) {
        localIntent.setAction(Intent.ACTION_VIEW);
        localIntent.setClassName("com.android.settings","com.android.settings.InstalledAppDetails");
        localIntent.putExtra("com.android.settings.ApplicationPkgName", context.getPackageName());
    }
    context.startActivity(localIntent);
}
 
Example 9
Project: IdealMedia   File: NavigationDrawerFragment.java   View Source Code Vote up 5 votes
private void rateThisApp() {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(Uri.parse("market://details?id=" + getActivity().getPackageName()));

    try {
        startActivity(intent);
    } catch (ActivityNotFoundException e) {
        intent.setData(Uri.parse("https://play.google.com/store/apps/details?id=" + getActivity().getPackageName()));
        try {
            startActivity(intent);
        } catch (ActivityNotFoundException e1) {
            Toast.makeText(getActivity(), getString(R.string.text_no_market_app), Toast.LENGTH_SHORT).show();
        }
    }
}
 
Example 10
Project: letv   File: PKDialog.java   View Source Code Vote up 5 votes
private void loadUrlWithBrowser(String str, String str2, String str3) throws Exception {
    Intent intent = new Intent();
    intent.setComponent(new ComponentName(str, str2));
    intent.setAction("android.intent.action.VIEW");
    intent.addFlags(1073741824);
    intent.addFlags(268435456);
    intent.setData(Uri.parse(str3));
    if (this.mWeakContext != null && this.mWeakContext.get() != null) {
        ((Context) this.mWeakContext.get()).startActivity(intent);
    }
}
 
Example 11
Project: mupdf-android-viewer-old   File: ChoosePDFActivity.java   View Source Code Vote up 5 votes
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
	super.onListItemClick(l, v, position, id);

	mPositions.put(mDirectory.getAbsolutePath(), getListView().getFirstVisiblePosition());

	if (position < (mParent == null ? 0 : 1)) {
		mDirectory = mParent;
		mHandler.post(mUpdateFiles);
		return;
	}

	position -= (mParent == null ? 0 : 1);

	if (position < mDirs.length) {
		mDirectory = mDirs[position];
		mHandler.post(mUpdateFiles);
		return;
	}

	position -= mDirs.length;

	Uri uri = Uri.fromFile(mFiles[position]);
	Intent intent = new Intent(this,MuPDFActivity.class);
	intent.setAction(Intent.ACTION_VIEW);
	intent.setData(uri);
	switch (mPurpose) {
	case PickPDF:
		// Start an activity to display the PDF file
		startActivity(intent);
		break;
	case PickKeyFile:
		// Return the uri to the caller
		setResult(RESULT_OK, intent);
		finish();
		break;
	}
}
 
Example 12
Project: RLibrary   File: RUtils.java   View Source Code Vote up 5 votes
/**
 * 快速加群
 */
public static boolean joinQQGroup(Context context, String key) {
    Intent intent = new Intent();
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setData(Uri.parse("mqqopensdkapi://bizAgent/qm/qr?url=http%3A%2F%2Fqm.qq.com%2Fcgi-bin%2Fqm%2Fqr%3Ffrom%3Dapp%26p%3Dandroid%26k%3D" + key));
    // 此Flag可根据具体产品需要自定义,如设置,则在加群界面按返回,返回手Q主界面,不设置,按返回会返回到呼起产品界面    //intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
    try {
        context.startActivity(intent);
        return true;
    } catch (Exception e) {
        // 未安装手Q或安装的版本不支持
        T_.error("您没有安装腾讯QQ");
        return false;
    }
}
 
Example 13
Project: yaacc-code   File: SyncAVTransportPlayer.java   View Source Code Vote up 5 votes
@Override
public PendingIntent getNotificationIntent() {
    Intent notificationIntent = new Intent(getContext(),
            AVTransportPlayerActivity.class);
    Log.d(getClass().getName(), "Put id into intent: " + getId());
    notificationIntent.setData(Uri.parse("http://0.0.0.0/" + getId() + "")); //just for making the intents different http://stackoverflow.com/questions/10561419/scheduling-more-than-one-pendingintent-to-same-activity-using-alarmmanager
    notificationIntent.putExtra(PLAYER_ID, getId());
    PendingIntent contentIntent = PendingIntent.getActivity(getContext(), 0,
            notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT);
    return contentIntent;
}
 
Example 14
Project: QuranAndroid   File: HomeActivity.java   View Source Code Vote up 4 votes
@Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int id = item.getItemId();

        if (id == R.id.action_translations) {
            //start translation activity
            startActivity(new Intent(this, TranslationsActivity.class));
            return true;
        } else if (id == R.id.last) {
            int lastPage = AppPreference.getLastPageRead();
            //check of there is no saved last page
            if (lastPage != -1) {
                startActivity(new Intent(this, QuranPageReadActivity.class)
                        .putExtra(AppConstants.General.PAGE_NUMBER, lastPage));
            } else {
                startActivity(new Intent(this, QuranPageReadActivity.class)
                        .putExtra(AppConstants.General.PAGE_NUMBER, 603));
            }

        } else if (id == R.id.search) {
            //Search view created in onCreateOptionMenu
            return false;
        } else if (id == R.id.action_jump) {
            //show popup
            new JumpToPopup(this);
        } else if (id == R.id.action_settings) {
            //settings activity
            startActivity(new Intent(this, SettingsActivity.class));
        } else if (id == R.id.action_about) {
            //about activity
            startActivity(new Intent(this, AboutActivity.class));
        } else if (id == R.id.action_share) {
            //share intent for the application
            Intent sharingIntent = new Intent(Intent.ACTION_SEND);
            sharingIntent.setType("text/plain");
            sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, "#"+getString(R.string.app_name)+"\n https://play.google.com/store/apps/details?id="+getPackageName());
            startActivity(Intent.createChooser(sharingIntent, "Share using"));
//            Toast.makeText(this, "App not published", Toast.LENGTH_SHORT).show();
        } else if (id == R.id.action_rate_app) {
            //market url of the application
            String url = "https://play.google.com/store/apps/details?id="+getPackageName();
            Intent i = new Intent(Intent.ACTION_VIEW);
            i.setData(Uri.parse(url));
            startActivity(i);
//            Toast.makeText(this, "App not published", Toast.LENGTH_SHORT).show();
        }

        return super.onOptionsItemSelected(item);
    }
 
Example 15
Project: AndroidApp-Deploy   File: MainActivity.java   View Source Code Vote up 4 votes
public void skycinemamax(View view){
    String videoUrl = "http://178.33.226.36:8000/live/olsi/olsi/678.ts";
    Intent i = new Intent(Intent.ACTION_VIEW);
    i.setData(Uri.parse(videoUrl));
    startActivity(i);
}
 
Example 16
Project: underlx   File: MainService.java   View Source Code Vote up 4 votes
private void handleAnnouncementNotification(String network, String title,
                                            String body, String url, String sourceId,
                                            long msgtime) {
    Log.d("MainService", "handleAnnouncementNotification");
    SharedPreferences sharedPref = getSharedPreferences("notifsettings", MODE_PRIVATE);
    Set<String> sourcePref = sharedPref.getStringSet("pref_notifs_announcement_sources", null);

    Intent notificationIntent = new Intent(Intent.ACTION_VIEW);
    notificationIntent.setData(Uri.parse(url));
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);

    Announcement.Source source = Announcement.getSource(sourceId);
    if (source == null) {
        return;
    }

    if (title.isEmpty()) {
        title = String.format(getString(R.string.notif_announcement_alt_title), getString(source.nameResourceId));
    }

    if (body.isEmpty()) {
        body = getString(R.string.frag_announcement_no_text);
    }

    NotificationCompat.BigTextStyle bigTextStyle = new NotificationCompat.BigTextStyle();
    bigTextStyle.setBigContentTitle(title);
    bigTextStyle.bigText(body);

    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setStyle(bigTextStyle)
            .setSmallIcon(R.drawable.ic_pt_ml_notif)
            .setColor(source.color)
            .setContentTitle(title)
            .setContentText(body)
            .setAutoCancel(true)
            .setWhen(msgtime)
            .setSound(Uri.parse(sharedPref.getString("pref_notifs_announcement_ringtone", "content://settings/system/notification_sound")))
            .setVisibility(Notification.VISIBILITY_PUBLIC)
            .setContentIntent(contentIntent);

    if (sharedPref.getBoolean("pref_notifs_announcement_vibrate", false)) {
        notificationBuilder.setVibrate(new long[]{0, 100, 100, 150, 150, 200});
    } else {
        notificationBuilder.setVibrate(new long[]{0l});
    }

    NotificationManager notificationManager =
            (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

    notificationManager.notify(url.hashCode(), notificationBuilder.build());
}
 
Example 17
Project: RxEasyHttp   File: LoginActivity.java   View Source Code Vote up 4 votes
public void startAppSettings() {
    Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
    intent.setData(Uri.parse("package:" + getPackageName()));
    startActivity(intent);
}
 
Example 18
Project: OpenAPK   File: Actions.java   View Source Code Vote up 4 votes
public static void settings(Context context, AppItem appItem) {
    Intent intent = new Intent();
    intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
    intent.setData(Uri.parse("package:" + appItem.getPackageName()));
    context.startActivity(intent);
}
 
Example 19
Project: AndroidApp-Deploy   File: MainActivity.java   View Source Code Vote up 4 votes
public void rai4(View view){
    String videoUrl = "http://www.q7t1.com:8000/live/sYKADDaJs2/SnoQc6v4hZ/1292.ts";
    Intent i = new Intent(Intent.ACTION_VIEW);
    i.setData(Uri.parse(videoUrl));
    startActivity(i);
}
 
Example 20
Project: Lunary-Ethereum-Wallet   File: MainActivity.java   View Source Code Vote up 4 votes
private void selectItem(int position) {
    switch (position) {
        case 1: {
            try {
                WalletStorage.getInstance(this).importingWalletsDetector(this);

            } catch (Exception e) {
                e.printStackTrace();
            }
            break;
        }
        case 2: {
            Intent settings = new Intent(this, rehanced.com.simpleetherwallet.activities.SettingsActivity.class);
            startActivityForResult(settings, rehanced.com.simpleetherwallet.activities.SettingsActivity.REQUEST_CODE);
            break;
        }
        case 3: {
            new AlertDialog.Builder(this)
                    .setTitle("About Lunary")
                    .setMessage("Lunary is published under GPL3\n" +
                            "Developed by Manuel S. C. for Rehanced, 2017\n"
                            + "www.rehanced.com\n" +
                            getString(R.string.translator_name) + "\n" +
                            "\nCredits:\n" +
                            "MaterialDrawer by Mike Penz\n" +
                            "MPAndroidChart by Philipp Jahoda\n" +
                            "Mobile Vision Barcode Scanner by KingsMentor\n" +
                            "XZING\n" +
                            "FloatingActionButton by Dmytro Tarianyk\n" +
                            "RateThisApp by Keisuke Kobayashi\n" +
                            "AppIntro by Maximilian Narr\n" +
                            "Material Dialogs by Aidan Michael Follestad\n" +
                            "Poloniex for price data\n" +
                            "Web3j by Conor Svensson\n" +
                            "PatternLock by Zhang Hai\n" +
                            "Ethereum Foundation for usage of the icon according to (CC A 3.0)\n" +
                            "Powered by Etherscan.io APIs\n" +
                            "Token balances powered by Ethplorer.io\n\n" +
                            "Lunary is published under GPL3\n" +
                            "This app is not associated with Ethereum or the Ethereum Foundation in any way. Lunary is an independend wallet app.")
                    .setIcon(android.R.drawable.ic_dialog_info)
                    .show();
            break;
        }
        case 4: {
            Intent i = new Intent(Intent.ACTION_VIEW);
            i.setData(Uri.parse("https://www.reddit.com/r/lunary"));
            startActivity(i);
            break;
        }
        case 5: {
            if (WalletStorage.getInstance(this).getFullOnly().size() == 0) {
                Dialogs.noFullWallet(this);
            } else {
                Intent donate = new Intent(this, SendActivity.class);
                donate.putExtra("TO_ADDRESS", "0xa9981a33f6b1A18da5Db58148B2357f22B44e1e0");
                startActivity(donate);
            }
            break;
        }
        default: {
            return;
        }
    }
}