当前位置: 首页>>代码示例>>Java>>正文


Java Intent.ACTION_VIEW属性代码示例

本文整理汇总了Java中android.content.Intent.ACTION_VIEW属性的典型用法代码示例。如果您正苦于以下问题:Java Intent.ACTION_VIEW属性的具体用法?Java Intent.ACTION_VIEW怎么用?Java Intent.ACTION_VIEW使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.content.Intent的用法示例。


在下文中一共展示了Intent.ACTION_VIEW属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: showMap

/**
 * This method will fire off an implicit Intent to view a location on a map.
 *
 * When constructing implicit Intents, you can use either the setData method or specify the
 * URI as the second parameter of the Intent's constructor,
 * as I do in {@link #openWebPage(String)}
 *
 * @param geoLocation The Uri representing the location that will be opened in the map
 */
private void showMap(Uri geoLocation) {
    /*
     * Again, we create an Intent with the action, ACTION_VIEW because we want to VIEW the
     * contents of this Uri.
     */
    Intent intent = new Intent(Intent.ACTION_VIEW);

    /*
     * Using setData to set the Uri of this Intent has the exact same affect as passing it in
     * the Intent's constructor. This is simply an alternate way of doing this.
     */
    intent.setData(geoLocation);
    if (intent.resolveActivity(getPackageManager()) != null) {
        startActivity(intent);
    }
}
 
开发者ID:fjoglar,项目名称:android-dev-challenge,代码行数:25,代码来源:MainActivity.java

示例2: onOptionsItemSelected

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int itemID = item.getItemId();

    switch (itemID) {
        case R.id.action_settings:
            Intent mapsActivity = new Intent(this, SettingsActivity.class);
            startActivity(mapsActivity);
            return true;
        case R.id.action_add:
            Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://juvenal.org"));
            startActivity(browserIntent);
    }

    return super.onOptionsItemSelected(item);
}
 
开发者ID:Jugendhackt,项目名称:Camera-warner,代码行数:16,代码来源:MapsActivity.java

示例3: openAudio

/**
 * 调用自带的音频播放器
 *
 * @param context
 * @param path
 */
private static void openAudio(Context context, String path) {
    File f = new File(path);
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setDataAndType(Uri.fromFile(f), "audio/*");// "audio/mp3"
    context.startActivity(intent);
}
 
开发者ID:lo625090140,项目名称:lqrwechatrongcloud,代码行数:13,代码来源:FileOpenUtils.java

示例4: openURL

final void openURL(String url) {
  // Strangely, some Android browsers don't seem to register to handle HTTP:// or HTTPS://.
  // Lower-case these as it should always be OK to lower-case these schemes.
  if (url.startsWith("HTTP://")) {
    url = "http" + url.substring(4);
  } else if (url.startsWith("HTTPS://")) {
    url = "https" + url.substring(5);
  }
  Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
  try {
    launchIntent(intent);
  } catch (ActivityNotFoundException anfe) {
    Log.w(TAG, "Nothing available to handle " + intent);
  }
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:15,代码来源:ResultHandler.java

示例5: installNormal

/**
 * 安装App
 *
 * @param context
 * @param filePath
 * @return
 */
public static boolean installNormal(Context context, String filePath) {
    Intent i = new Intent(Intent.ACTION_VIEW);
    java.io.File file = new java.io.File(filePath);
    if (file == null || !file.exists() || !file.isFile() || file.length() <= 0) {
        return false;
    }

    i.setDataAndType(Uri.parse("file://" + filePath), "application/vnd.android.package-archive");
    i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(i);
    return true;
}
 
开发者ID:lzmlsfe,项目名称:19porn,代码行数:19,代码来源:Kits.java

示例6: premiumsport2

public void premiumsport2(View view){
    String videoUrl = "http://178.33.226.36:8000/live/olsi/olsi/1176.ts";
    Intent i = new Intent(Intent.ACTION_VIEW);
    i.setData(Uri.parse(videoUrl));
    startActivity(i);
}
 
开发者ID:Francescopaolo44,项目名称:AndroidApp-Deploy,代码行数:6,代码来源:MainActivity.java

示例7: onClick

@Override
public void onClick(View v) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    switch (v.getId()){
        case R.id.github:
            intent.setData(Uri.parse("http://Github.com/LynnYuki"));
            break;
        case R.id.blog:
            intent.setData(Uri.parse("https://lynnyuki.github.io"));
            break;
    }
    startActivity(intent);
}
 
开发者ID:LynnYuki,项目名称:CoolCloud-Weather,代码行数:13,代码来源:AboutApplicationActivity.java

示例8: onCreate

@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	requestWindowFeature(Window.FEATURE_NO_TITLE);
	getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
			WindowManager.LayoutParams.FLAG_FULLSCREEN);
	setContentView(R.layout.ease_showvideo_activity);
	loadingLayout = (RelativeLayout) findViewById(R.id.loading_layout);
	progressBar = (ProgressBar) findViewById(R.id.progressBar);

	final EMMessage message = getIntent().getParcelableExtra("msg");
	if (!(message.getBody() instanceof EMVideoMessageBody)) {
		Toast.makeText(EaseShowVideoActivity.this, "Unsupported message body", Toast.LENGTH_SHORT).show();
		finish();
		return;
	}
	EMVideoMessageBody messageBody = (EMVideoMessageBody)message.getBody();

	localFilePath = messageBody.getLocalUrl();

	if (localFilePath != null && new File(localFilePath).exists()) {
		Intent intent = new Intent(Intent.ACTION_VIEW);
		intent.setDataAndType(Uri.fromFile(new File(localFilePath)),
				"video/mp4");
		startActivity(intent);
		finish();
	} else {
		EMLog.d(TAG, "download remote video file");
		downloadVideo(message);
	}
}
 
开发者ID:funnyzhaov,项目名称:Tribe,代码行数:31,代码来源:EaseShowVideoActivity.java

示例9: onDownloadStart

@Override
public void onDownloadStart(String url, String userAgent, String contentDisposition,
                            String mimetype, long contentLength) {
    Log.d(TAG, "onDownloadStart() called with: url = [" + url + "], userAgent = [" +
            userAgent + "], contentDisposition = [" + contentDisposition + "], " +
            "mimetype = [" + mimetype + "], contentLength = [" + contentLength + "]");
    try {
        Uri uri = Uri.parse(url);
        Intent intent = new Intent(Intent.ACTION_VIEW, uri);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:fendoudebb,项目名称:PlayAndroid,代码行数:15,代码来源:WebViewActivity.java

示例10: createIntentForGooglePlay

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;
}
 
开发者ID:mgks,项目名称:Android-SmartWebView,代码行数:8,代码来源:IntentHelper.java

示例11: openInstagram

public void openInstagram(View view) {
    Uri uri = Uri.parse("https://instagram.com/_u/trinity.djsce/");
    Intent likeIng = new Intent(Intent.ACTION_VIEW, uri);

    likeIng.setPackage("com.instagram.android");

    try {
        startActivity(likeIng);
    } catch (ActivityNotFoundException e) {
        startActivity(new Intent(Intent.ACTION_VIEW,
                Uri.parse("https://instagram.com/trinity.djsce/")));
    }
}
 
开发者ID:Ronak-59,项目名称:Trinity-App,代码行数:13,代码来源:MainActivity.java

示例12: handleMessage

@Override
public void handleMessage(Message message) {
	if (message.what == R.id.restart_preview) {
		restartPreviewAndDecode();

	} else if (message.what == R.id.decode_succeeded) {
		state = State.SUCCESS;
		Bundle bundle = message.getData();
		Bitmap barcode = null;
		float scaleFactor = 1.0f;
		if (bundle != null) {
			byte[] compressedBitmap = bundle
					.getByteArray(DecodeThread.BARCODE_BITMAP);
			if (compressedBitmap != null) {
				barcode = BitmapFactory.decodeByteArray(compressedBitmap,
						0, compressedBitmap.length, null);
				// Mutable copy:
				barcode = barcode.copy(Bitmap.Config.ARGB_8888, true);
			}
			scaleFactor = bundle
					.getFloat(DecodeThread.BARCODE_SCALED_FACTOR);
		}
		activity.handleDecode((Result) message.obj, barcode, scaleFactor);

	} else if (message.what == R.id.decode_failed) {// We're decoding as fast as possible, so when one decode fails,
		// start another.
		state = State.PREVIEW;
		cameraManager.requestPreviewFrame(decodeThread.getHandler(),
				R.id.decode);

	} else if (message.what == R.id.return_scan_result) {
		activity.setResult(Activity.RESULT_OK, (Intent) message.obj);
		activity.finish();

	} else if (message.what == R.id.launch_product_query) {
		String url = (String) message.obj;

		Intent intent = new Intent(Intent.ACTION_VIEW);
		intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
		intent.setData(Uri.parse(url));

		ResolveInfo resolveInfo = activity.getPackageManager()
				.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY);
		String browserPackageName = null;
		if (resolveInfo != null && resolveInfo.activityInfo != null) {
			browserPackageName = resolveInfo.activityInfo.packageName;
			Log.d(TAG, "Using browser in package " + browserPackageName);
		}

		// Needed for default Android browser / Chrome only apparently
		if ("com.android.browser".equals(browserPackageName)
				|| "com.android.chrome".equals(browserPackageName)) {
			intent.setPackage(browserPackageName);
			intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
			intent.putExtra(Browser.EXTRA_APPLICATION_ID,
					browserPackageName);
		}

		try {
			activity.startActivity(intent);
		} catch (ActivityNotFoundException ignored) {
			Log.w(TAG, "Can't find anything to handle VIEW of URI " + url);
		}

	}
}
 
开发者ID:yun2win,项目名称:tvConnect_android,代码行数:66,代码来源:CaptureActivityHandler.java

示例13: openMarket

private static void openMarket(Context context, String appURI, String webURI) {
    // you can also use BuildConfig.APPLICATION_ID
    //String appId = "com.google.android.apps.books";
    Intent rateIntent = new Intent(Intent.ACTION_VIEW,
            Uri.parse(appURI));
    boolean marketFound = false;

    // find all applications able to handle our rateIntent
    final List<ResolveInfo> otherApps = context.getPackageManager()
            .queryIntentActivities(rateIntent, 0);
    for (ResolveInfo otherApp : otherApps) {
        // look for Google Play application
        if (otherApp.activityInfo.applicationInfo.packageName
                .equals("com.android.vending")) {

            ActivityInfo otherAppActivity = otherApp.activityInfo;
            ComponentName componentName = new ComponentName(
                    otherAppActivity.applicationInfo.packageName,
                    otherAppActivity.name
            );
            // make sure it does NOT open in the stack of your activity
            rateIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            // task re-parenting if needed
            rateIntent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
            // if the Google Play was already open in a search result
            //  this make sure it still go to the app page you requested
            rateIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            // this make sure only the Google Play app is allowed to
            // intercept the intent
            rateIntent.setComponent(componentName);
            context.startActivity(rateIntent);
            marketFound = true;
            break;

        }
    }

    // if GP not present on device, open web browser
    if (!marketFound) {
        Intent webIntent = new Intent(Intent.ACTION_VIEW,
                Uri.parse(webURI));
        context.startActivity(webIntent);
    }
}
 
开发者ID:fekracomputers,项目名称:IslamicLibraryAndroid,代码行数:44,代码来源:AboutUtil.java

示例14: goOnFacebookPage

@OnClick(R.id.facebook)
public void goOnFacebookPage() {
    Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(FACEBOOK_URI));
    startActivity(browserIntent);
}
 
开发者ID:Augugrumi,项目名称:SpaceRace,代码行数:5,代码来源:CreditsActivity.java

示例15: browserIntent

private Intent browserIntent(String url) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(Uri.parse(url));
    return intent;
}
 
开发者ID:prakh25,项目名称:MovieApp,代码行数:5,代码来源:PeopleExternalLinksWrapper.java


注:本文中的android.content.Intent.ACTION_VIEW属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。