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


Java Intent.addCategory方法代码示例

本文整理汇总了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);
        }
    }
}
 
开发者ID:BittleDragon,项目名称:MyRepository,代码行数:18,代码来源:DownloadService.java

示例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);
    }
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:23,代码来源:Accounts.java

示例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");
  }
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:44,代码来源:ShareModule.java

示例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);
}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:32,代码来源:UWXEventModule.java

示例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;
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:27,代码来源:Func.java

示例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;
}
 
开发者ID:alescdb,项目名称:LauncherTV,代码行数:23,代码来源:Utils.java

示例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);
}
 
开发者ID:yangjiantao,项目名称:AndroidUiKit,代码行数:10,代码来源:HomeActivity.java

示例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;
}
 
开发者ID:MobileDev418,项目名称:AndroidBackendlessChat,代码行数:9,代码来源:ExitHelper.java

示例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;
}
 
开发者ID:bunnyblue,项目名称:NoticeDog,代码行数:15,代码来源:AppIds.java

示例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;
    }
}
 
开发者ID:hshare,项目名称:MVPArmsTest1,代码行数:14,代码来源:DeviceUtils.java

示例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);
}
 
开发者ID:Vavassor,项目名称:Tusky,代码行数:13,代码来源:ComposeActivity.java

示例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);

    }
 
开发者ID:remerber,项目名称:FastEc,代码行数:11,代码来源:CameraHandler.java

示例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);
    }
 
开发者ID:shawnsky,项目名称:RantApp,代码行数:9,代码来源:LauncherActivity.java

示例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);
}
 
开发者ID:liying2008,项目名称:Simpler,代码行数:17,代码来源:ActivityInvokeAPI.java

示例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);
}
 
开发者ID:1313ou,项目名称:Treebolic,代码行数:15,代码来源:MainActivity.java


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