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


Java Activity.setIntent方法代碼示例

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


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

示例1: tryUpdateIntentFromBeam

import android.app.Activity; //導入方法依賴的package包/類
/**
 * Checks to see if the activity's intent ({@link android.app.Activity#getIntent()}) is
 * an NFC intent that the app recognizes. If it is, then parse the NFC message and set the
 * activity's intent (using {@link Activity#setIntent(android.content.Intent)}) to something
 * the app can recognize (i.e. a normal {@link Intent#ACTION_VIEW} intent).
 */
public static void tryUpdateIntentFromBeam(Activity activity) {
    Intent originalIntent = activity.getIntent();
    if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(originalIntent.getAction())) {
        Parcelable[] rawMsgs = originalIntent.getParcelableArrayExtra(
                NfcAdapter.EXTRA_NDEF_MESSAGES);
        NdefMessage msg = (NdefMessage) rawMsgs[0];
        // Record 0 contains the MIME type, record 1 is the AAR, if present.
        // In iosched, AARs are not present.
        NdefRecord mimeRecord = msg.getRecords()[0];
        if (ScheduleContract.makeContentItemType(
                ScheduleContract.Sessions.CONTENT_TYPE_ID).equals(
                new String(mimeRecord.getType()))) {
            // Re-set the activity's intent to one that represents session details.
            Intent sessionDetailIntent = new Intent(Intent.ACTION_VIEW,
                    Uri.parse(new String(mimeRecord.getPayload())));
            activity.setIntent(sessionDetailIntent);
        }
    }
}
 
開發者ID:dreaminglion,項目名稱:iosched-reader,代碼行數:26,代碼來源:BeamUtils.java

示例2: tryTranslateHttpIntent

import android.app.Activity; //導入方法依賴的package包/類
/**
 * If an activity's intent is for a Google I/O web URL that the app can handle
 * natively, this method translates the intent to the equivalent native intent.
 */
public static void tryTranslateHttpIntent(Activity activity) {
    Intent intent = activity.getIntent();
    if (intent == null) {
        return;
    }

    Uri uri = intent.getData();
    if (uri == null || TextUtils.isEmpty(uri.getPath())) {
        return;
    }

    Uri sessionDetailWebUrlPrefix = Uri.parse(Config.SESSION_DETAIL_WEB_URL_PREFIX);
    String prefixPath = sessionDetailWebUrlPrefix.getPath();
    String path = uri.getPath();

    if (sessionDetailWebUrlPrefix.getScheme().equals(uri.getScheme()) &&
            sessionDetailWebUrlPrefix.getHost().equals(uri.getHost()) &&
            path.startsWith(prefixPath)) {
        String sessionId = path.substring(prefixPath.length());
        activity.setIntent(new Intent(
                Intent.ACTION_VIEW,
                ScheduleContract.Sessions.buildSessionUri(sessionId)));
    }
}
 
開發者ID:dreaminglion,項目名稱:iosched-reader,代碼行數:29,代碼來源:UIUtils.java

示例3: newActivity

import android.app.Activity; //導入方法依賴的package包/類
@Override
public Activity newActivity(ClassLoader cl, String className, Intent intent) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
    try {
        cl.loadClass(className);
    } catch (ClassNotFoundException e) {
        LoadedPlugin plugin = this.mPluginManager.getLoadedPlugin(intent);
        String targetClassName = PluginUtil.getTargetActivity(intent);

        Log.i(TAG, String.format("newActivity[%s : %s]", className, targetClassName));

        if (targetClassName != null) {
            Activity activity = mBase.newActivity(plugin.getClassLoader(), targetClassName, intent);
            activity.setIntent(intent);

            try {
                // for 4.1+
                ReflectUtil.setField(ContextThemeWrapper.class, activity, "mResources", plugin.getResources());
            } catch (Exception ignored) {
                // ignored.
            }

            return activity;
        }
    }

    return mBase.newActivity(cl, className, intent);
}
 
開發者ID:didi,項目名稱:VirtualAPK,代碼行數:28,代碼來源:VAInstrumentation.java

示例4: onWXEntryActivityOnNewIntent

import android.app.Activity; //導入方法依賴的package包/類
/**
 * 在WXEntryActivity onNewIntent方法中執行
 */

public static void onWXEntryActivityOnNewIntent(Activity wXPayEntryActivity, Intent intent, IWXAPIEventHandler iwxapiEventHandler){
    wXPayEntryActivity.setIntent(intent);
    api.handleIntent(intent, iwxapiEventHandler);
}
 
開發者ID:haihaio,項目名稱:AmenWeather,代碼行數:9,代碼來源:WXEntryActivityUtils.java


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