當前位置: 首頁>>代碼示例>>Java>>正文


Java Intent.resolveActivityInfo方法代碼示例

本文整理匯總了Java中android.content.Intent.resolveActivityInfo方法的典型用法代碼示例。如果您正苦於以下問題:Java Intent.resolveActivityInfo方法的具體用法?Java Intent.resolveActivityInfo怎麽用?Java Intent.resolveActivityInfo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.content.Intent的用法示例。


在下文中一共展示了Intent.resolveActivityInfo方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: startActivity

import android.content.Intent; //導入方法依賴的package包/類
private void startActivity(String action, Uri uri, String type, Map<String, String> extras, boolean bExpectResult, int requestCode, CallbackContext callbackContext) {
    //  Credit: https://github.com/chrisekelley/cordova-webintent
    Intent i = (uri != null ? new Intent(action, uri) : new Intent(action));

    if (type != null && uri != null) {
        i.setDataAndType(uri, type); //Fix the crash problem with android 2.3.6
    } else {
        if (type != null) {
            i.setType(type);
        }
        if (uri != null)
        {
            i.setData(uri);
        }
    }

    for (String key : extras.keySet()) {
        String value = extras.get(key);
        // If type is text html, the extra text must sent as HTML
        if (key.equals(Intent.EXTRA_TEXT) && type.equals("text/html")) {
            i.putExtra(key, Html.fromHtml(value));
        } else if (key.equals(Intent.EXTRA_STREAM)) {
            // allowes sharing of images as attachments.
            // value in this case should be a URI of a file
            final CordovaResourceApi resourceApi = webView.getResourceApi();
            i.putExtra(key, resourceApi.remapUri(Uri.parse(value)));
        } else if (key.equals(Intent.EXTRA_EMAIL)) {
            // allows to add the email address of the receiver
            i.putExtra(Intent.EXTRA_EMAIL, new String[] { value });
        } else {
            i.putExtra(key, value);
        }
    }

    i.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

    if (i.resolveActivityInfo(this.cordova.getActivity().getPackageManager(), 0) != null)
    {
    if (bExpectResult)
    {
        cordova.setActivityResultCallback(this);
        ((CordovaActivity) this.cordova.getActivity()).startActivityForResult(i, requestCode);
    }
    else
        {
        ((CordovaActivity)this.cordova.getActivity()).startActivity(i);
            callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK));
        }
    }
    else
    {
        //  Return an error as there is no app to handle this intent
        callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR));
    }
}
 
開發者ID:darryncampbell,項目名稱:darryncampbell-cordova-plugin-intent,代碼行數:56,代碼來源:IntentShim.java

示例2: startEmbeddedActivity

import android.content.Intent; //導入方法依賴的package包/類
public EmbeddedActivityRecord startEmbeddedActivity(String bundleName) throws Exception{
    EmbeddedActivityRecord activityRecord = new EmbeddedActivityRecord();
    activityRecord.id = "embedded_"+mParent.getClass().getSimpleName();
    Field mThemeResourceF = AndroidHack.findField(mParent,"mThemeResource");
    int mThemeResource = (Integer)mThemeResourceF.get(mParent);
    Intent intent = new Intent();
    intent.setClassName(mParent,EmbeddedActivity.class.getName());
    intent.putExtra("themeId",mThemeResource);
    intent.putExtra("bundleName",bundleName);
    ActivityInfo info = intent.resolveActivityInfo(mParent.getPackageManager(), PackageManager.GET_ACTIVITIES);
    activityRecord.activity = (EmbeddedActivity) ActivityThread_startActivityNow.invoke(AndroidHack.getActivityThread(),
            mParent, activityRecord.id, intent, info, activityRecord.activity, null, null);
    activityRecord.activityInfo = info;
    return activityRecord;
}
 
開發者ID:alibaba,項目名稱:atlas,代碼行數:16,代碼來源:RemoteActivityManager.java

示例3: launchWifiSettings

import android.content.Intent; //導入方法依賴的package包/類
public static void launchWifiSettings(Context context) {
    // context.startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
    Intent intent = new Intent(WifiManager.ACTION_PICK_WIFI_NETWORK);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    if (intent.resolveActivityInfo(context.getPackageManager(), 0) != null) {
        context.startActivity(intent);
    }
}
 
開發者ID:victordiaz,項目名稱:phonk,代碼行數:10,代碼來源:PhonkAppHelper.java

示例4: launchHotspotSettings

import android.content.Intent; //導入方法依賴的package包/類
public static void launchHotspotSettings(Context context) {
    // context.startActivity(new Intent(WifiManager.AC));

    final Intent intent = new Intent(Intent.ACTION_MAIN, null);
    intent.addCategory(Intent.CATEGORY_LAUNCHER);
    final ComponentName cn = new ComponentName("com.android.settings", "com.android.settings.TetherSettings");
    intent.setComponent(cn);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    if (intent.resolveActivityInfo(context.getPackageManager(), 0) != null) {
        context.startActivity(intent);
    }
}
 
開發者ID:victordiaz,項目名稱:phonk,代碼行數:14,代碼來源:PhonkAppHelper.java

示例5: openDirectory

import android.content.Intent; //導入方法依賴的package包/類
private void openDirectory(final Uri dirUri, final CallbackContext callbackContext) {
    final Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setDataAndType(dirUri, "resource/folder");

    final PackageManager packageManager = cordovaInstance.getActivity().getPackageManager();
    if (intent.resolveActivityInfo(packageManager, 0) != null) {
        cordovaInstance.getActivity().startActivity(intent);
        callbackContext.success();
    } else {
        callbackContext.error(RETURN_CODE.NO_FILE_MANAGER_FOUND.name());
    }
}
 
開發者ID:kolbasa,項目名稱:cordova-logcat-filelogger,代碼行數:13,代碼來源:LogCatPlugin.java


注:本文中的android.content.Intent.resolveActivityInfo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。