本文整理汇总了Java中android.content.Intent.addCategory方法的典型用法代码示例。如果您正苦于以下问题:Java Intent.addCategory方法的具体用法?Java Intent.addCategory怎么用?Java Intent.addCategory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.Intent
的用法示例。
在下文中一共展示了Intent.addCategory方法的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: performExport
import android.content.Intent; //导入方法依赖的package包/类
private void performExport(final boolean includeGlobals, final Account account) {
// TODO, prompt to allow a user to choose which accounts to export
ArrayList<String> accountUuids = null;
if (account != null) {
accountUuids = new ArrayList<>();
accountUuids.add(account.getUuid());
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
exportGlobalSettings = includeGlobals;
exportAccountUuids = accountUuids;
Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
intent.setType("application/octet-stream");
intent.putExtra(Intent.EXTRA_TITLE, SettingsExporter.generateDatedExportFileName());
intent.addCategory(Intent.CATEGORY_OPENABLE);
startActivityForResult(intent, ACTIVITY_REQUEST_SAVE_SETTINGS_FILE);
} else {
startExport(includeGlobals, accountUuids, null);
}
}
示例3: share
import android.content.Intent; //导入方法依赖的package包/类
/**
* Open a chooser dialog to send text content to other apps.
*
* Refer http://developer.android.com/intl/ko/training/sharing/send.html
*
* @param content the data to send
* @param dialogTitle the title of the chooser dialog
*/
@ReactMethod
public void share(ReadableMap content, String dialogTitle, Promise promise) {
if (content == null) {
promise.reject(ERROR_INVALID_CONTENT, "Content cannot be null");
return;
}
try {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setTypeAndNormalize("text/plain");
if (content.hasKey("title")) {
intent.putExtra(Intent.EXTRA_SUBJECT, content.getString("title"));
}
if (content.hasKey("message")) {
intent.putExtra(Intent.EXTRA_TEXT, content.getString("message"));
}
Intent chooser = Intent.createChooser(intent, dialogTitle);
chooser.addCategory(Intent.CATEGORY_DEFAULT);
Activity currentActivity = getCurrentActivity();
if (currentActivity != null) {
currentActivity.startActivity(chooser);
} else {
getReactApplicationContext().startActivity(chooser);
}
WritableMap result = Arguments.createMap();
result.putString("action", ACTION_SHARED);
promise.resolve(result);
} catch (Exception e) {
promise.reject(ERROR_UNABLE_TO_OPEN_DIALOG, "Failed to open share dialog");
}
}
示例4: openURL
import android.content.Intent; //导入方法依赖的package包/类
@JSMethod
public void openURL(String url) {
if (TextUtils.isEmpty(url)) {
return;
}
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.parse(url);
String scheme = uri.getScheme();
if (TextUtils.equals("tel", scheme)) {
} else if (TextUtils.equals("sms", scheme)) {
} else if (TextUtils.equals("mailto", scheme)) {
} else if (TextUtils.equals("http", scheme) ||
TextUtils.equals("https",
scheme)) {
intent.putExtra("isLocal", false);
intent.addCategory(WEEX_CATEGORY);
} else if (TextUtils.equals("file", scheme)) {
intent.putExtra("isLocal", true);
intent.addCategory(WEEX_CATEGORY);
} else {
intent.addCategory(WEEX_CATEGORY);
uri = Uri.parse(new StringBuilder("http:").append(url).toString());
}
intent.setData(uri);
mWXSDKInstance.getContext().startActivity(intent);
}
示例5: getInstalledPackages
import android.content.Intent; //导入方法依赖的package包/类
public static List<ResolveInfo> getInstalledPackages(PackageManager pm, Context context) {
DebugLog log = DebugLog.get(context);
if (log.isEnabled()) {
log.writeLog("Getting installed packages. Will try a few different methods to see if I receive a suitable app list.");
}
Intent startupIntent = new Intent(Intent.ACTION_MAIN);
startupIntent.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> resolveInfos = pm.queryIntentActivities(startupIntent, 0);
if (log.isEnabled()) {
log.writeLog("Got " + resolveInfos.size() + " apps via queryIntentActivities.");
}
List<ApplicationInfo> appInfos = pm.getInstalledApplications(PackageManager.GET_META_DATA);
if (log.isEnabled()) {
log.writeLog("Got " + appInfos.size() + " apps via getInstalledApplications with GET_META_DATA.");
}
appInfos = pm.getInstalledApplications(0);
if (log.isEnabled()) {
log.writeLog("Got " + appInfos.size() + " apps via getInstalledApplications with no flags");
}
return resolveInfos;
}
示例6: loadApplications
import android.content.Intent; //导入方法依赖的package包/类
public static List<AppInfo> loadApplications(Context context) {
PackageManager packageManager = context.getPackageManager();
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> intentActivities = packageManager.queryIntentActivities(mainIntent, 0);
List<AppInfo> entries = new ArrayList<>();
if (intentActivities != null) {
for (ResolveInfo resolveInfo : intentActivities) {
if (!context.getPackageName().equals(resolveInfo.activityInfo.packageName))
entries.add(new AppInfo(packageManager, resolveInfo));
}
}
Collections.sort(entries, new Comparator<AppInfo>() {
@Override
public int compare(AppInfo lhs, AppInfo rhs) {
return lhs.getName().compareToIgnoreCase(rhs.getName());
}
});
return entries;
}
示例7: onListItemClick
import android.content.Intent; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected void onListItemClick(ListView l, View v, int position, long id) {
Map<String, Object> map = (Map<String, Object>)l.getItemAtPosition(position);
Intent intent = new Intent((Intent) map.get("intent"));
intent.addCategory(APP_CAGEGORY);
startActivity(intent);
}
示例8: call
import android.content.Intent; //导入方法依赖的package包/类
@Override
public Object call() throws Exception {
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
activity.startActivity(intent);
return null;
}
示例9: getSMSAppPackageName
import android.content.Intent; //导入方法依赖的package包/类
@TargetApi(19)
public static String getSMSAppPackageName(Context context) {
if (VERSION.SDK_INT >= 19) {
return Sms.getDefaultSmsPackage(context);
}
Intent intent = new Intent("android.intent.action.MAIN");
intent.addCategory("android.intent.category.DEFAULT");
intent.setType("vnd.android-dir/mms-sms");
ComponentName componentName = intent.resolveActivity(context.getPackageManager());
if (componentName != null) {
return componentName.getPackageName();
}
return null;
}
示例10: openAppActivity
import android.content.Intent; //导入方法依赖的package包/类
public static boolean openAppActivity(Context context, String packageName,
String activityName) {
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
ComponentName cn = new ComponentName(packageName, activityName);
intent.setComponent(cn);
try {
context.startActivity(intent);
return true;
} catch (Exception e) {
return false;
}
}
示例11: initiateMediaPicking
import android.content.Intent; //导入方法依赖的package包/类
private void initiateMediaPicking() {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
intent.setType("image/* video/*");
} else {
String[] mimeTypes = new String[]{"image/*", "video/*"};
intent.setType("*/*");
intent.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes);
}
startActivityForResult(intent, MEDIA_PICK_RESULT);
}
示例12: pickPhoto
import android.content.Intent; //导入方法依赖的package包/类
private void pickPhoto() {
final Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
DELEGATE.startActivityForResult
(Intent.createChooser(intent, "选择获取图片的方式"), RequestCodes.PICK_PHOTO);
}
示例13: onBackPressed
import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onBackPressed() {
// super.onBackPressed();
Intent i = new Intent(Intent.ACTION_MAIN);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
i.addCategory(Intent.CATEGORY_HOME);
startActivity(i);
}
示例14: openMessageListByUid
import android.content.Intent; //导入方法依赖的package包/类
/**
* 打开私信对话界面。
*
* @param activity
* @param uid 用户uid
*/
public static void openMessageListByUid(Activity activity,String uid){
if(activity==null){
return;
}
Intent intent=new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.addCategory("android.intent.category.DEFAULT");
intent.setData(Uri.parse("sinaweibo://messagelist?uid="+uid));
activity.startActivity(intent);
}
示例15: requestTreebolicSource
import android.content.Intent; //导入方法依赖的package包/类
/**
* Request Treebolic source
*/
private void requestTreebolicSource()
{
final String extensions = (String) this.pluginProvider.get(Providers.EXTENSIONS);
final Intent intent = new Intent(this, org.treebolic.filechooser.FileChooserActivity.class);
intent.setType((String) this.pluginProvider.get(Providers.MIMETYPE));
intent.putExtra(FileChooserActivity.ARG_FILECHOOSER_INITIAL_DIR, (String) this.pluginProvider.get(Providers.BASE));
intent.putExtra(FileChooserActivity.ARG_FILECHOOSER_EXTENSION_FILTER, extensions == null ? null : extensions.split(","));
intent.addCategory(Intent.CATEGORY_OPENABLE);
startActivityForResult(intent, MainActivity.REQUEST_FILE_CODE);
}