當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。