本文整理汇总了Java中android.content.Intent.setData方法的典型用法代码示例。如果您正苦于以下问题:Java Intent.setData方法的具体用法?Java Intent.setData怎么用?Java Intent.setData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.Intent
的用法示例。
在下文中一共展示了Intent.setData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: installAPK
import android.content.Intent; //导入方法依赖的package包/类
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);
}
}
}
示例2: ajoinQQGroupdata
import android.content.Intent; //导入方法依赖的package包/类
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;
}
}
示例3: openPreferredLocationInMap
import android.content.Intent; //导入方法依赖的package包/类
/**
* 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!");
}
}
示例4: updateWidgetListView
import android.content.Intent; //导入方法依赖的package包/类
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;
}
示例5: cardHeaderClicked
import android.content.Intent; //导入方法依赖的package包/类
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);
}
示例6: playWithCoub
import android.content.Intent; //导入方法依赖的package包/类
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);
}
示例7: findKnownBrowsers
import android.content.Intent; //导入方法依赖的package包/类
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);
}
}
示例8: startSettingIntent
import android.content.Intent; //导入方法依赖的package包/类
/**
* 启动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);
}
示例9: rateThisApp
import android.content.Intent; //导入方法依赖的package包/类
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();
}
}
}
示例10: loadUrlWithBrowser
import android.content.Intent; //导入方法依赖的package包/类
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);
}
}
示例11: onListItemClick
import android.content.Intent; //导入方法依赖的package包/类
@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;
}
}
示例12: joinQQGroup
import android.content.Intent; //导入方法依赖的package包/类
/**
* 快速加群
*/
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;
}
}
示例13: getNotificationIntent
import android.content.Intent; //导入方法依赖的package包/类
@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;
}
示例14: onOptionsItemSelected
import android.content.Intent; //导入方法依赖的package包/类
@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);
}
示例15: skycinemamax
import android.content.Intent; //导入方法依赖的package包/类
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);
}