Java Code Examples for android.content.Intent#ACTION_VIEW

The following examples show how to use android.content.Intent#ACTION_VIEW . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PebbleSync.java    From xDrip-Experimental with GNU General Public License v3.0 7 votes vote down vote up
public static void sideloadInstall(Context ctx, String assetFilename) {
    Log.d(TAG, "sideloadInstall: About to install app " + assetFilename);
    try {
        // Read .pbw from assets/
        Intent intent = new Intent(Intent.ACTION_VIEW);
        File file = new File(ctx.getExternalFilesDir(null), assetFilename);
        InputStream is = ctx.getResources().getAssets().open(assetFilename);
        OutputStream os = new FileOutputStream(file);
        byte[] pbw = new byte[is.available()];
        is.read(pbw);
        os.write(pbw);
        is.close();
        os.close();

        // Install via Pebble Android app
        intent.setDataAndType(Uri.fromFile(file), "application/pbw");
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        ctx.startActivity(intent);
    } catch (IOException e) {
        Toast.makeText(ctx, "App install failed: " + e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
    }
}
 
Example 2
Source File: LoginActivity.java    From patrol-android with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onClick(View v) {
    switch (v.getId()) {
        case R.id.loginButton:
            if (isPrivacyAccepted) {
                if (isEmailValid(emailEditText.getText().toString())) {
                    loginUser(emailEditText.getText().toString());
                }
            } else {
                Toast.makeText(this, R.string.terms_and_privacy_error, Toast.LENGTH_SHORT)
                        .show();
            }
            break;
        case R.id.copyrightLayout:
            Intent intent = new Intent(
                    Intent.ACTION_VIEW,
                    Uri.parse(getResources().getString(R.string.website_url)));
            startActivity(intent);
            break;
    }
}
 
Example 3
Source File: SearchActivity.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
public void loadUrl(String url) {
    // Wait until native has loaded.
    if (!mIsActivityUsable) {
        mQueuedUrl = url;
        return;
    }

    // Don't do anything if the input was empty. This is done after the native check to prevent
    // resending a queued query after the user deleted it.
    if (TextUtils.isEmpty(url)) return;

    // Fix up the URL and send it to the full browser.
    String fixedUrl = UrlFormatter.fixupUrl(url);
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(fixedUrl));
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
    intent.setClass(this, ChromeLauncherActivity.class);
    IntentHandler.addTrustedIntentExtras(intent);
    IntentUtils.safeStartActivity(this, intent,
            ActivityOptionsCompat
                    .makeCustomAnimation(this, android.R.anim.fade_in, android.R.anim.fade_out)
                    .toBundle());
    RecordUserAction.record("SearchWidget.SearchMade");
    finish();
}
 
Example 4
Source File: FileUtil.java    From FileManager with Apache License 2.0 5 votes vote down vote up
/**
 * 打开音频资源
 * @param context
 * @param file
 */
public static void openMusicIntent( Context context , File file ){
    Uri path = Uri.fromFile(file);
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.setDataAndType(path, "audio/*");
    context.startActivity(intent);
}
 
Example 5
Source File: IntentHelper.java    From AppPlus with MIT License 5 votes vote down vote up
static Intent createIntentForGooglePlay(Context context) {
    String packageName = context.getPackageName();
    Intent intent = new Intent(Intent.ACTION_VIEW, getGooglePlay(packageName));
    if (isPackageExists(context, GOOGLE_PLAY_PACKAGE_NAME)) {
        intent.setPackage(GOOGLE_PLAY_PACKAGE_NAME);
    }
    return intent;
}
 
Example 6
Source File: UpdateManager.java    From qingyang with Apache License 2.0 5 votes vote down vote up
/**
 * 安装apk
 */
private void installApk() {
	File apkFile = new File(apkFilePath);

	if (!apkFile.exists()) {
		return;
	}
	Intent i = new Intent(Intent.ACTION_VIEW);
	i.setDataAndType(Uri.parse("file://" + apkFile.toString()),
			"application/vnd.android.package-archive");
	context.startActivity(i);
}
 
Example 7
Source File: AppApplicationMgr.java    From AndroidWallet with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 安装应用
 *
 * @param context
 * @param filePath
 * @return
 */
public static boolean installApk(Context context, String filePath) {
    File file = new File(filePath);
    if (!file.exists() || !file.isFile() || file.length() <= 0) {
        return false;
    }
    Intent i = new Intent(Intent.ACTION_VIEW);
    i.setDataAndType(Uri.parse("file://" + filePath), "application/vnd.android.package-archive");
    i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(i);
    return true;
}
 
Example 8
Source File: Utility.java    From iBeebo with GNU General Public License v3.0 5 votes vote down vote up
public static boolean isGooglePlaySafe(Activity activity) {
    Uri uri = Uri.parse("http://play.google.com/store/apps/details?id=com.google.android.gms");
    Intent mapCall = new Intent(Intent.ACTION_VIEW, uri);
    mapCall.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
    mapCall.setPackage("com.android.vending");
    PackageManager packageManager = activity.getPackageManager();
    List<ResolveInfo> activities = packageManager.queryIntentActivities(mapCall, 0);
    return activities.size() > 0;
}
 
Example 9
Source File: ConnectUsActivity.java    From AssistantBySDK with Apache License 2.0 5 votes vote down vote up
/**
 * 跳转到官网
 **/
private void gotoWebsite(String url) {
    try {
        Uri uri = Uri.parse("http://" + url);
        Intent intent = new Intent(Intent.ACTION_VIEW, uri);
        startActivity(intent);
    } catch (ActivityNotFoundException e) {
        e.printStackTrace();
        new CommonDialog(this, "提示信息", "检测到您没有可用的浏览器,请先安装!", "确定").show();
    }

}
 
Example 10
Source File: FuncUnit.java    From CoolClock with GNU General Public License v3.0 5 votes vote down vote up
public static void openURL(Context c, String url) {
    if (url == null)
        return;
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
    c.startActivity(intent);
}
 
Example 11
Source File: SingleParallaxListView.java    From ParallaxScroll with MIT License 5 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
	if (item.getItemId() == R.id.action_github) {
		Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/nirhart/ParallaxScroll"));
		startActivity(browserIntent);
	}
	return true;
}
 
Example 12
Source File: UserOverviewFragment.java    From intra42 with Apache License 2.0 5 votes vote down vote up
@Override
public void onClick(View v) {
    if (v == layoutPhone) {
        Intent intent = new Intent(Intent.ACTION_DIAL);
        intent.setData(Uri.parse("tel:" + user.phone));
        startActivity(intent);
    } else if (v == imageButtonSMS) {
        Intent sendIntent = new Intent(Intent.ACTION_VIEW);
        sendIntent.setData(Uri.parse("sms:" + user.phone));
        startActivity(sendIntent);
    } else if (v == layoutMail) {
        Intent testIntent = new Intent(Intent.ACTION_VIEW);
        Uri data = Uri.parse("mailto:?to=" + user.email);
        testIntent.setData(data);
        startActivity(testIntent);
    } else if (v == layoutLocation) {
        LocationHistoryActivity.openItWithUser(getContext(), user);
    } else if (v == buttonFriend) {
        ApiService42Tools api = app.getApiService42Tools();

        setButtonFriends(0);
        if (isFriend == null)
            return;
        if (!isFriend) { //add
            Call<Friends> friendsCall = api.addFriend(user.id);
            friendsCall.enqueue(addFriend);
            Analytics.friendAdd();
        } else {
            api.deleteFriend(user.id).enqueue(removeFriend);
            Analytics.friendRemove();
        }
    } else if (v == imageViewProfile) {
        ImageViewerActivity.openIt(getContext(), user);
    }
}
 
Example 13
Source File: AbstractInfoFragment.java    From Kore with Apache License 2.0 4 votes vote down vote up
protected void playItemLocally(String url, String type) {
    Uri uri = Uri.parse(url);
    Intent intent = new Intent(Intent.ACTION_VIEW, uri);
    intent.setDataAndType(uri, type);
    startActivity(intent);
}
 
Example 14
Source File: Utils.java    From droidddle with Apache License 2.0 4 votes vote down vote up
public static String getShotViewIntent(Shot shot) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(Uri.parse(shot.htmlUrl));
    return intent.toUri(Intent.URI_INTENT_SCHEME);
}
 
Example 15
Source File: ForumPostActivity.java    From BotLibre with Eclipse Public License 1.0 4 votes vote down vote up
public void openWebsite() {
	Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(MainActivity.WEBSITE + "/forum-post?id=" + this.instance.id));
	startActivity(intent);
}
 
Example 16
Source File: ChatAdapter.java    From FlyWoo with Apache License 2.0 4 votes vote down vote up
private void openFile(View v, File f) {
    Intent it = new Intent(Intent.ACTION_VIEW);
    Uri uri = Uri.fromFile(f);
    it.setDataAndType(uri, "*/*");
    v.getContext().startActivity(it);
}
 
Example 17
Source File: ThreadActivity.java    From Ouroboros with GNU General Public License v3.0 4 votes vote down vote up
public void doPositiveClickExternal(String url) {
    Intent i = new Intent(Intent.ACTION_VIEW);
    i.setData(Uri.parse(url));
    startActivity(i);
}
 
Example 18
Source File: AboutActivity.java    From call_manage with MIT License 4 votes vote down vote up
@OnClick(R.id.about_bugs)
public void openBugReporting(View v) {
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.app_bug_reporting_url)));
    startActivity(intent);
}
 
Example 19
Source File: App.java    From sms-ticket with Apache License 2.0 4 votes vote down vote up
public static Intent getOpenMarketIntent(Context context) {
    Intent i = new Intent(Intent.ACTION_VIEW);
    i.setData(Uri.parse("market://details?id=" + context.getPackageName()));
    i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    return i;
}
 
Example 20
Source File: AuthorizationClient.java    From android-auth with Apache License 2.0 2 votes vote down vote up
/**
 * Triggers an intent to open the Spotify accounts service in a browser. Make sure that the
 * redirectUri is set to an URI your app is registered for in your AndroidManifest.xml. To
 * get your clientId and to set the redirectUri, please see the
 * <a href="https://developer.spotify.com/my-applications">my applications</a>
 * part of our developer site.
 *
 * @param contextActivity The activity that should start the intent to open a browser.
 * @param request         Authorization request
 */
public static void openLoginInBrowser(Activity contextActivity, AuthorizationRequest request) {
    Intent launchBrowser = new Intent(Intent.ACTION_VIEW, request.toUri());
    contextActivity.startActivity(launchBrowser);
}