android.content.Intent#ACTION_VIEW源码实例Demo

下面列出了android.content.Intent#ACTION_VIEW 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: xDrip-Experimental   文件: PebbleSync.java
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();
    }
}
 
源代码2 项目: 365browser   文件: SearchActivity.java
@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();
}
 
源代码3 项目: patrol-android   文件: LoginActivity.java
@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;
    }
}
 
源代码4 项目: intra42   文件: UserOverviewFragment.java
@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);
    }
}
 
源代码5 项目: ParallaxScroll   文件: SingleParallaxListView.java
@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;
}
 
源代码6 项目: CoolClock   文件: FuncUnit.java
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);
}
 
源代码7 项目: AssistantBySDK   文件: ConnectUsActivity.java
/**
 * 跳转到官网
 **/
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();
    }

}
 
源代码8 项目: FileManager   文件: FileUtil.java
/**
 * 打开音频资源
 * @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);
}
 
源代码9 项目: iBeebo   文件: Utility.java
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;
}
 
源代码10 项目: AndroidWallet   文件: AppApplicationMgr.java
/**
 * 安装应用
 *
 * @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;
}
 
源代码11 项目: qingyang   文件: UpdateManager.java
/**
 * 安装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);
}
 
源代码12 项目: AppPlus   文件: IntentHelper.java
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;
}
 
源代码13 项目: Kore   文件: AbstractInfoFragment.java
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);
}
 
源代码14 项目: Ouroboros   文件: ThreadActivity.java
public void doPositiveClickExternal(String url) {
    Intent i = new Intent(Intent.ACTION_VIEW);
    i.setData(Uri.parse(url));
    startActivity(i);
}
 
源代码15 项目: FlyWoo   文件: ChatAdapter.java
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);
}
 
源代码16 项目: droidddle   文件: Utils.java
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);
}
 
源代码17 项目: BotLibre   文件: ForumPostActivity.java
public void openWebsite() {
	Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(MainActivity.WEBSITE + "/forum-post?id=" + this.instance.id));
	startActivity(intent);
}
 
源代码18 项目: call_manage   文件: AboutActivity.java
@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);
}
 
源代码19 项目: sms-ticket   文件: App.java
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;
}
 
源代码20 项目: android-auth   文件: AuthorizationClient.java
/**
 * 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);
}
 
 方法所在类
 同类方法