当前位置: 首页>>代码示例>>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;未经允许,请勿转载。