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


Java Intent.getBundleExtra方法代码示例

本文整理汇总了Java中android.content.Intent.getBundleExtra方法的典型用法代码示例。如果您正苦于以下问题:Java Intent.getBundleExtra方法的具体用法?Java Intent.getBundleExtra怎么用?Java Intent.getBundleExtra使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.content.Intent的用法示例。


在下文中一共展示了Intent.getBundleExtra方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createFromAlApplinkData

import android.content.Intent; //导入方法依赖的package包/类
private static AppLinkData createFromAlApplinkData(Intent intent) {
    Bundle applinks = intent.getBundleExtra(BUNDLE_AL_APPLINK_DATA_KEY);
    if (applinks == null) {
        return null;
    }

    AppLinkData appLinkData = new AppLinkData();
    appLinkData.targetUri = intent.getData();
    if (appLinkData.targetUri == null) {
        String targetUriString = applinks.getString(METHOD_ARGS_TARGET_URL_KEY);
        if (targetUriString != null) {
            appLinkData.targetUri = Uri.parse(targetUriString);
        }
    }
    appLinkData.argumentBundle = applinks;
    appLinkData.arguments = null;
    Bundle refererData = applinks.getBundle(ARGUMENTS_REFERER_DATA_KEY);
    if (refererData != null) {
        appLinkData.ref = refererData.getString(REFERER_DATA_REF_KEY);
    }

    return appLinkData;
}
 
开发者ID:MobileDev418,项目名称:AndroidBackendlessChat,代码行数:24,代码来源:AppLinkData.java

示例2: onReceive

import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onReceive(final Context context, Intent intent) {
    final PendingResult result = goAsync();

    // If app restriction settings are already created, they will be included in the Bundle
    // as key/value pairs.
    final Bundle existingRestrictions =
            intent.getBundleExtra(Intent.EXTRA_RESTRICTIONS_BUNDLE);
    Log.i(TAG, "existingRestrictions = " + existingRestrictions);

    new Thread() {
        public void run() {
            createRestrictions(context, result, existingRestrictions);
        }
    }.start();
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:17,代码来源:GetRestrictionsReceiver.java

示例3: callActivityOnResume

import android.content.Intent; //导入方法依赖的package包/类
@Override
public void callActivityOnResume(Activity activity) {
    VirtualCore.get().getComponentDelegate().beforeActivityResume(activity);
    VActivityManager.get().onActivityResumed(activity);
    super.callActivityOnResume(activity);
    VirtualCore.get().getComponentDelegate().afterActivityResume(activity);
    Intent intent = activity.getIntent();
    if (intent != null) {
        Bundle bundle = intent.getBundleExtra("_VA_|_sender_");
        if (bundle != null) {
            IBinder callbackToken = BundleCompat.getBinder(bundle, "_VA_|_ui_callback_");
            IUiCallback callback = IUiCallback.Stub.asInterface(callbackToken);
            if (callback != null) {
                try {
                    callback.onAppOpened(VClientImpl.get().getCurrentPackage(), VUserHandle.myUserId());
                } catch (RemoteException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
 
开发者ID:7763sea,项目名称:VirtualHook,代码行数:23,代码来源:AppInstrumentation.java

示例4: onStartCommand

import android.content.Intent; //导入方法依赖的package包/类
public int onStartCommand(Intent intent, int flags, int startId) {
    LogInfo.log(TAG, "onStartCommand");
    if (intent == null) {
        stopSelf();
        return -1;
    }
    if (!(this.mWindowManager == null || this.mFloatingWindowPlayerView == null)) {
        this.mFloatingWindowPlayerController.onFinish();
        this.mWindowManager.removeView(this.mFloatingWindowPlayerView);
        this.mFloatingWindowPlayerView = null;
    }
    this.mOldNetworkState = NetworkUtils.getNetworkType();
    Bundle bundle = intent.getBundleExtra(LetvConstant.Intent.Bundle.PLAY);
    this.mVideoParams = parseVideoParams(bundle);
    this.mFloatingWindowPlayerView = new FloatingWindowPlayerView(this);
    this.mFloatingWindowPlayerView.setVideoParams(this.mVideoParams);
    this.mFloatingWindowPlayerView.setWindowManager(this.mWindowManager);
    LogInfo.log(TAG, "Service中设置FloatingWindowPlayerController");
    this.mFloatingWindowPlayerView.load();
    this.mFloatingWindowPlayerController = this.mFloatingWindowPlayerView.getFloatingWindowPlayerController();
    this.mFloatingWindowPlayerController.setBundle(bundle);
    registerBroadcastReceiver();
    return 3;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:25,代码来源:FloatingWindowPlayerService.java

示例5: getMessageId

import android.content.Intent; //导入方法依赖的package包/类
String getMessageId(Intent intent) {
    String sid = null;
    Bundle payload = intent.getBundleExtra("payload");
    if (payload != null) {
        String customData = payload.getString("u");
        try {
            sid = new JSONObject(customData).getString("sid");
        } catch (JSONException e) {
        }
    }
    return sid;
}
 
开发者ID:emartech,项目名称:android-mobile-engage-sdk,代码行数:13,代码来源:MobileEngageInternal.java

示例6: onActivityResult

import android.content.Intent; //导入方法依赖的package包/类
@Override 
public void onActivityResult(int requestCode, int resultCode, Intent data) {     
	super.onActivityResult(requestCode, resultCode, data); 
	int nMode = MFPFileManagerActivity.START_FILE_MANAGER_BY_ITSELF;
	switch(requestCode) { 
		case (SCRIPT_FILE_MANAGER_ACTIVITY) : { 
			if (resultCode == Activity.RESULT_OK) {
				Bundle bundle = data.getBundleExtra("android.intent.extra.SelectedFile");
				if (bundle != null && bundle.getString("SelectedFilePath") != null) {
					mstrSelectedFilePath = bundle.getString("SelectedFilePath");
					nMode = bundle.getInt("FileManagerOpenMode");
				}
			} else 	{
				return;	// do nothing
			}
			break;
		} 
	}
	if (nMode == MFPFileManagerActivity.START_FILE_MANAGER_TO_OPEN_BY_SCRIPT_EDITOR)	{
		if (mstrSelectedFilePath.equals("") == false)	{
			openFile(mstrSelectedFilePath);
		}			
	} else if (nMode == MFPFileManagerActivity.START_FILE_MANAGER_TO_SAVE_BY_SCRIPT_EDITOR)	{
		if (mstrSelectedFilePath.equals("") == false)	{
			saveFile(mstrSelectedFilePath);
		}			
	}
	if (mstrNextTask.equals("openNewFile"))	{
		openNewFile();
		mstrNextTask = "";
	} else if (mstrNextTask.equals("finish"))	{
		finish();
		// need not to set mstrNextTask = "";
	}
}
 
开发者ID:woshiwpa,项目名称:SmartMath,代码行数:36,代码来源:ScriptEditorActivity.java

示例7: getCallIdFromIntent

import android.content.Intent; //导入方法依赖的package包/类
public static UUID getCallIdFromIntent(Intent intent) {
    if (intent == null) {
        return null;
    }
    int version = getProtocolVersionFromIntent(intent);
    String callIdString = null;
    if (isVersionCompatibleWithBucketedIntent(version)) {
        Bundle bridgeArgs = intent.getBundleExtra(EXTRA_PROTOCOL_BRIDGE_ARGS);
        if (bridgeArgs != null) {
            callIdString = bridgeArgs.getString(BRIDGE_ARG_ACTION_ID_STRING);
        }
    } else {
        callIdString = intent.getStringExtra(EXTRA_PROTOCOL_CALL_ID);
    }

    UUID callId = null;
    if (callIdString != null) {
        try {
            callId = UUID.fromString(callIdString);
        } catch (IllegalArgumentException exception) {
        }
    }
    return callId;
}
 
开发者ID:eviltnan,项目名称:kognitivo,代码行数:25,代码来源:NativeProtocol.java

示例8: initFromIntent

import android.content.Intent; //导入方法依赖的package包/类
protected void initFromIntent(int pageValue, Intent data) {
    if (data == null) {
        throw new RuntimeException("you must provide a page info to display");
    }
    SimpleBackPage page = SimpleBackPage.getPageByValue(pageValue);
    if (page == null) {
        throw new IllegalArgumentException("can not find page by value:" + pageValue);
    }

    setActionBarTitle(page.getTitle());

    try {
        Fragment fragment = (Fragment) page.getClz().newInstance();

        Bundle args = data.getBundleExtra(BUNDLE_KEY_ARGS);
        if (args != null) {
            fragment.setArguments(args);
        }

        FragmentTransaction trans = getSupportFragmentManager()
                .beginTransaction();
        trans.replace(R.id.container, fragment, TAG);
        trans.commitAllowingStateLoss();

        mFragment = new WeakReference<>(fragment);
    } catch (Exception e) {
        e.printStackTrace();
        throw new IllegalArgumentException(
                "generate fragment error. by value:" + pageValue);
    }
}
 
开发者ID:hsj-xiaokang,项目名称:OSchina_resources_android,代码行数:32,代码来源:SimpleBackActivity.java

示例9: getValue

import android.content.Intent; //导入方法依赖的package包/类
/**
 * Get a value from an intent by a giving class and key.
 * @param intent
 *  the source intent
 * @param key
 *  the key of the value
 * @param clz
 *  the class of the value
 * @return
 *  the value from the source intent
 */
public static Object getValue(Intent intent, String key, Class<?> clz) {
    Object value = null;
    // Cause it is not an easy job to handle inheritance in apt, it is a lot easier to put the code in the Android environment.
    if(Bundle.class.isAssignableFrom(clz)) {
        // bundle implements parcelable, so it should place before parcelable.
        value = intent.getBundleExtra(key);
    } else if(Parcelable.class.isAssignableFrom(clz)) {
        value = intent.getParcelableExtra(key);
    } else if(Parcelable[].class.isAssignableFrom(clz)) {
        value = intent.getParcelableArrayExtra(key);
    } else if(boolean[].class.isAssignableFrom(clz)) {
        value = intent.getBooleanArrayExtra(key);
    } else if(byte[].class.isAssignableFrom(clz)) {
        value = intent.getByteArrayExtra(key);
    } else if(short[].class.isAssignableFrom(clz)) {
        value = intent.getShortArrayExtra(key);
    } else if(char[].class.isAssignableFrom(clz)) {
        value = intent.getCharArrayExtra(key);
    } else if(int[].class.isAssignableFrom(clz)) {
        value = intent.getIntArrayExtra(key);
    } else if(long[].class.isAssignableFrom(clz)) {
        value = intent.getLongArrayExtra(key);
    } else if(float[].class.isAssignableFrom(clz)) {
        value = intent.getFloatArrayExtra(key);
    } else if(double[].class.isAssignableFrom(clz)) {
        value = intent.getDoubleArrayExtra(key);
    } else if(String[].class.isAssignableFrom(clz)) {
        value = intent.getStringArrayExtra(key);
    } else if(CharSequence[].class.isAssignableFrom(clz)) {
        value = intent.getCharSequenceArrayExtra(key);
    } else if(Serializable.class.isAssignableFrom(clz)) {
        // some of the above are assignable for serializable, so serializable should be in the last place.
        value = intent.getSerializableExtra(key);
    } else {
        throw new RuntimeException(clz + " is not compatible with intent (key=" + key + ")");
    }

    return value;
}
 
开发者ID:foreveruseful,项目名称:smartkey,代码行数:51,代码来源:IntentValueGetter.java

示例10: onNewIntent

import android.content.Intent; //导入方法依赖的package包/类
public void onNewIntent(Intent intent) {
    if (intent.hasExtra("notification")) {//用户点击通知栏消息
        Bundle bundle = intent.getBundleExtra("notification");
        bundle.putBoolean("foreground", false);
        intent.putExtra("notification", bundle);
        mJsDelivery.notifyNotification(bundle);
    }
}
 
开发者ID:zzzkk2009,项目名称:react-native-leancloud-sdk,代码行数:9,代码来源:RNPushNotificationModule.java

示例11: fromIntent

import android.content.Intent; //导入方法依赖的package包/类
/**
 * Retrieve an object that was packed into an {@link Intent} via
 * {@link #putExtra(Intent, Object)}.
 * @param intent the {@link Intent} to unpack.
 * @param clazz the {@link Class} of the object to deserialize from the {@link Intent}.
 * @return an object of type {@code T}, or {@code null} if no object was found.
 */
public static <T> T fromIntent(Intent intent, Class<T> clazz) {
    String key = getClassKey(clazz);
    Bundle bundle = intent.getBundleExtra(key);
    if (bundle == null) {
        return null;
    }

    return fromBundle(bundle, clazz);
}
 
开发者ID:google,项目名称:easybundler,代码行数:17,代码来源:EasyBundler.java

示例12: onStart

import android.content.Intent; //导入方法依赖的package包/类
@Override
protected void onStart() {
    super.onStart();
    Intent intent = getIntent();
    Bundle bundle = intent.getBundleExtra("floatbox");
    if (shouldRestoreFloat && bundle != null) {
        onRestoreFloatBox(bundle);
    }
}
 
开发者ID:hushengjun,项目名称:FastAndroid,代码行数:10,代码来源:BaseCallActivity.java

示例13: initBaseData

import android.content.Intent; //导入方法依赖的package包/类
public void initBaseData() {
    Intent intent = ((Activity) this.mContext).getIntent();
    if (intent != null) {
        boolean z;
        this.mFrom = intent.getIntExtra("from", 0);
        if (intent.getSerializableExtra(PlayConstant.VIDEO_TYPE) == VideoType.Panorama) {
            z = true;
        } else {
            z = false;
        }
        this.mIsPanoramaVideo = z;
        this.mChannelName = intent.getStringExtra(PlayConstant.LIVE_CHANNEL_NAME);
        this.mChannelNum = intent.getStringExtra(PlayConstant.LIVE_CHANNEL_LUNBO_NUMBER);
        this.mCode = intent.getStringExtra("code");
        this.mProgramName = intent.getStringExtra(PlayConstant.LIVE_PROGRAM_NAME);
        this.mChannelId = intent.getStringExtra(PlayConstant.LIVE_CHANNEL_ID);
        this.mSignal = intent.getStringExtra(PlayConstant.LIVE_CHANNEL_SIGNAL);
        LogInfo.log("clf", "initBaseData....mChannelId=" + this.mChannelId);
        this.mPushLiveId = intent.getStringExtra(PlayConstant.LIVE_LAUNCH_ID);
        this.mUniqueId = intent.getStringExtra(PlayConstant.LIVE_ID);
        LogInfo.log("clf", "....mUniqueId=" + this.mUniqueId + ",mPushLiveId=" + this.mPushLiveId);
        Bundle payBundle = intent.getBundleExtra(PlayConstant.BUNDLE_KEY_YC_PARAM);
        if (payBundle != null) {
            this.mIsPay = payBundle.getBoolean(PlayConstant.LIVE_IS_PAY, false);
            this.mScreenings = payBundle.getString(PlayConstant.LIVE_SCREENINGS);
            this.mHomeImgUrl = payBundle.getString(PlayConstant.LIVE_HOME_ICON);
            this.mGuestImgUrl = payBundle.getString(PlayConstant.LIVE_GUEST_ICON);
            this.mPlayTime = payBundle.getString("play_time");
        } else {
            this.mIsPay = intent.getBooleanExtra(PlayConstant.LIVE_IS_PAY, false);
            this.mScreenings = intent.getStringExtra(PlayConstant.LIVE_SCREENINGS);
            this.mHomeImgUrl = intent.getStringExtra(PlayConstant.LIVE_HOME_ICON);
            this.mGuestImgUrl = intent.getStringExtra(PlayConstant.LIVE_GUEST_ICON);
            this.mPlayTime = intent.getStringExtra("play_time");
        }
        this.mOldNetState = NetworkUtils.getNetworkType();
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:39,代码来源:BasePlayLiveFlow.java

示例14: assertIntentMatchesJobInfo

import android.content.Intent; //导入方法依赖的package包/类
private void assertIntentMatchesJobInfo(Intent intent, JobInfo job) {
    assertEquals(GcmScheduler.ACTION_SCHEDULE, intent.getAction());
    assertEquals(GcmScheduler.PACKAGE_GMS, intent.getPackage());
    assertEquals(GcmScheduler.SCHEDULER_ACTION_SCHEDULE_TASK,
                 intent.getStringExtra(GcmScheduler.BUNDLE_PARAM_SCHEDULER_ACTION));
    assertThat(intent.getParcelableExtra(GcmScheduler.BUNDLE_PARAM_TOKEN), instanceOf(PendingIntent.class));

    assertEquals(job.getId(), (int) Integer.valueOf(intent.getStringExtra(GcmScheduler.PARAM_TAG)));
    assertEquals(GcmJobService.class.getName(), intent.getStringExtra(GcmScheduler.PARAM_SERVICE));
    assertTrue(intent.getBooleanExtra(GcmScheduler.PARAM_UPDATE_CURRENT, false));
    assertEquals(job.isPersisted(), intent.getBooleanExtra(GcmScheduler.PARAM_PERSISTED, false));

    if (job.hasEarlyConstraint() || job.hasLateConstraint()) {
        assertEquals(GcmScheduler.TRIGGER_TYPE_EXECUTION_WINDOW,
                     intent.getIntExtra(GcmScheduler.PARAM_TRIGGER_TYPE, -1));
        if (job.isPeriodic()) {
            assertEquals(TimeUnit.MILLISECONDS.toSeconds(job.getIntervalMillis()),
                         intent.getLongExtra(GcmScheduler.PARAM_TRIGGER_WINDOW_PERIOD, -1L));
            assertEquals(TimeUnit.MILLISECONDS.toSeconds(job.getIntervalMillis()),
                         intent.getLongExtra(GcmScheduler.PARAM_TRIGGER_WINDOW_FLEX, -1L));
        } else {
            assertEquals(TimeUnit.MILLISECONDS.toSeconds(job.getMinLatencyMillis()),
                         intent.getLongExtra(GcmScheduler.PARAM_TRIGGER_WINDOW_START, -1L));
            if (job.hasLateConstraint()) {
                assertEquals(TimeUnit.MILLISECONDS.toSeconds(job.getMaxExecutionDelayMillis()),
                             intent.getLongExtra(GcmScheduler.PARAM_TRIGGER_WINDOW_END, -1L));
            } else {
                assertEquals(TimeUnit.DAYS.toSeconds(7),
                             intent.getLongExtra(GcmScheduler.PARAM_TRIGGER_WINDOW_END, -1L));
            }
        }
    } else if (job.getTriggerContentUris() != null) {
        JobInfo.TriggerContentUri[] triggerContentUris = job.getTriggerContentUris();
        int size = triggerContentUris.length;
        Uri[] uriArray = new Uri[size];
        int[] flagsArray = new int[size];
        for (int i = 0; i < size; i++) {
            JobInfo.TriggerContentUri triggerContentUri = triggerContentUris[i];
            uriArray[i] = triggerContentUri.getUri();
            flagsArray[i] = triggerContentUri.getFlags();
        }
        assertEquals(GcmScheduler.TRIGGER_TYPE_CONTENT_URI,
                     intent.getIntExtra(GcmScheduler.PARAM_TRIGGER_TYPE, -1));
        assertArrayEquals(uriArray, intent.getParcelableArrayExtra(GcmScheduler.PARAM_CONTENT_URI_ARRAY));
        assertArrayEquals(flagsArray, intent.getIntArrayExtra(GcmScheduler.PARAM_CONTENT_URI_FLAGS_ARRAY));
    } else {
        assertEquals(GcmScheduler.TRIGGER_TYPE_IMMEDIATE,
                     intent.getIntExtra(GcmScheduler.PARAM_TRIGGER_TYPE, -1));
        assertEquals(0L, intent.getLongExtra(GcmScheduler.PARAM_TRIGGER_WINDOW_START, -1L));
        assertEquals(1L, intent.getLongExtra(GcmScheduler.PARAM_TRIGGER_WINDOW_END, -1L));
    }

    assertEquals(job.isRequireCharging(), intent.getBooleanExtra(PARAM_REQUIRES_CHARGING, false));
    int requiredNetwork = GcmScheduler.NETWORK_STATE_ANY;
    switch (job.getNetworkType()) {
        case JobInfo.NETWORK_TYPE_ANY:
            requiredNetwork = GcmScheduler.NETWORK_STATE_CONNECTED;
            break;

        case JobInfo.NETWORK_TYPE_UNMETERED:
            requiredNetwork = GcmScheduler.NETWORK_STATE_UNMETERED;
            break;

        default:
            requiredNetwork = GcmScheduler.NETWORK_STATE_ANY;
            break;
    }
    assertEquals(requiredNetwork, intent.getIntExtra(GcmScheduler.PARAM_REQUIRED_NETWORK, -1));

    Bundle retryStrategy = intent.getBundleExtra(GcmScheduler.PARAM_RETRY_STRATEGY);
    int backoffPolicy = job.getBackoffPolicy() == JobInfo.BACKOFF_POLICY_LINEAR
                        ? GcmScheduler.RETRY_POLICY_LINEAR : GcmScheduler.RETRY_POLICY_EXPONENTIAL;
    assertEquals(backoffPolicy, retryStrategy.getInt(GcmScheduler.PARAM_RETRY_STRATEGY_POLICY, -1));
    assertEquals(TimeUnit.MILLISECONDS.toSeconds(job.getInitialBackoffMillis()),
                 retryStrategy.getInt(GcmScheduler.PARAM_RETRY_STRATEGY_INITIAL_BACKOFF_SEC, -1));
    assertEquals(TimeUnit.HOURS.toSeconds(5),
                 retryStrategy.getInt(GcmScheduler.PARAM_RETRY_STRATEGY_MAXIMUM_BACKOFF_SEC, -1));

    assertEquals(job.getExtras().toMap(10),
                 new PersistableBundle(intent.getBundleExtra(GcmScheduler.PARAM_EXTRAS)).toMap(10));
}
 
开发者ID:Doist,项目名称:JobSchedulerCompat,代码行数:82,代码来源:GcmSchedulerTest.java

示例15: onReceive

import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
    if (!ACTION_FIRE_SETTING.equals(intent.getAction())) {
        return;
    }

    final Bundle bundle = intent.getBundleExtra(EXTRA_BUNDLE);
    if (isBundleValid(bundle)) {
        String commands = bundle.getString(BUNDLE_EXTRA_STRING_MESSAGE);
        if (commands != null) {
            String[] cs = commands.split(DIVIDER);
            Log.i(TAG + ": " + getClass().getSimpleName(), "Applying " + cs[0]);
            if (Prefs.getBoolean("showtaskertoast", true, context)) {
                Utils.toast(context.getString(R.string.applying_profile, cs[0]), context, Toast.LENGTH_LONG);
            }

            if (cs.length > 1) {
                RootUtils.SU su = new RootUtils.SU();
                for (int i = 1; i < cs.length; i++) {
                    if (cs[i].isEmpty()) {
                        continue;
                    }
                    synchronized (this) {
                        CPUFreq.ApplyCpu applyCpu;
                        if (cs[i].startsWith("#") && (applyCpu =
                                new CPUFreq.ApplyCpu(cs[i].substring(1))).toString() != null) {
                            for (String applyCpuCommand : ApplyOnBoot.getApplyCpu(applyCpu, su)) {
                                Log.i(TAG + ": " + getClass().getSimpleName(), "Run: " + applyCpuCommand);
                                su.runCommand(applyCpuCommand);
                            }
                        } else {
                            Log.i(TAG + ": " + getClass().getSimpleName(), "Run: " + cs[i]);
                            su.runCommand(cs[i]);
                        }
                    }
                }
                su.close();
            }
        }
    }
}
 
开发者ID:AyushR1,项目名称:KernelAdiutor-Mod,代码行数:42,代码来源:Tasker.java


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