本文整理汇总了Java中android.content.Intent.removeExtra方法的典型用法代码示例。如果您正苦于以下问题:Java Intent.removeExtra方法的具体用法?Java Intent.removeExtra怎么用?Java Intent.removeExtra使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.Intent
的用法示例。
在下文中一共展示了Intent.removeExtra方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fragmentArgumentsToIntent
import android.content.Intent; //导入方法依赖的package包/类
/**
* Converts a fragment arguments bundle into an intent.
*/
public static Intent fragmentArgumentsToIntent(Bundle arguments) {
Intent intent = new Intent();
if (arguments == null) {
return intent;
}
final Uri data = arguments.getParcelable("_uri");
if (data != null) {
intent.setData(data);
}
intent.putExtras(arguments);
intent.removeExtra("_uri");
return intent;
}
示例2: handleInstallShortcutIntent
import android.content.Intent; //导入方法依赖的package包/类
private Intent handleInstallShortcutIntent(Intent intent) {
Intent shortcut = intent.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT);
if (shortcut != null) {
ComponentName component = shortcut.resolveActivity(VirtualCore.getPM());
if (component != null) {
String pkg = component.getPackageName();
Intent newShortcutIntent = new Intent();
newShortcutIntent.setClassName(getHostPkg(), Constants.SHORTCUT_PROXY_ACTIVITY_NAME);
newShortcutIntent.addCategory(Intent.CATEGORY_DEFAULT);
newShortcutIntent.putExtra("_VA_|_intent_", shortcut);
newShortcutIntent.putExtra("_VA_|_uri_", shortcut.toUri(0));
newShortcutIntent.putExtra("_VA_|_user_id_", VUserHandle.myUserId());
intent.removeExtra(Intent.EXTRA_SHORTCUT_INTENT);
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, newShortcutIntent);
Intent.ShortcutIconResource icon = intent.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE);
if (icon != null && !TextUtils.equals(icon.packageName, getHostPkg())) {
try {
Resources resources = VirtualCore.get().getResources(pkg);
if (resources != null) {
int resId = resources.getIdentifier(icon.resourceName, "drawable", pkg);
if (resId > 0) {
Drawable iconDrawable = resources.getDrawable(resId);
Bitmap newIcon = BitmapUtils.drawableToBitmap(iconDrawable);
if (newIcon != null) {
intent.removeExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE);
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, newIcon);
}
}
}
} catch (Throwable e) {
e.printStackTrace();
}
}
}
}
return intent;
}
示例3: postCleanup
import android.content.Intent; //导入方法依赖的package包/类
private void postCleanup() {
if (mLauncher != null) {
// Remove any drag params from the launcher intent since the drag operation is complete.
Intent newIntent = new Intent(mLauncher.getIntent());
newIntent.removeExtra(EXTRA_PIN_ITEM_DRAG_LISTENER);
mLauncher.setIntent(newIntent);
}
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
removeListener();
}
});
}
示例4: startActivity
import android.content.Intent; //导入方法依赖的package包/类
@Override
public void startActivity(Intent intent) {
if (intent.getStringExtra(Browser.EXTRA_APPLICATION_ID) != null) {
intent.removeExtra(Browser.EXTRA_APPLICATION_ID);
}
try {
super.startActivity(intent);
} catch (ActivityNotFoundException e) {
Log.w(TAG, e);
Toast.makeText(this, R.string.ConversationActivity_there_is_no_app_available_to_handle_this_link_on_your_device, Toast.LENGTH_LONG).show();
}
}
示例5: onNewIntent
import android.content.Intent; //导入方法依赖的package包/类
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
if (intent != null && intent.getExtras() != null)
{
if (DEBUG) Timber.d("From login");
fromLoginActivity = intent.getExtras().getBoolean(FROM_LOGIN, false);
// So we wont encounter this flag again.
intent.removeExtra(FROM_LOGIN);
}
}
示例6: rebindRefMap
import android.content.Intent; //导入方法依赖的package包/类
/**
* 如果 oldIntent 绑定了 RefMap,那么将其解绑并重新绑定到 newIntent
*/
public void rebindRefMap(Intent oldIntent, Intent newIntent) {
if (hasRefMap(oldIntent)) {
Map<String, Object> refMap = getRefMap(oldIntent);
sGlobalRefMap.remove(getKeyOfMap(oldIntent));
oldIntent.removeExtra(KEY_OF_MAP);
int keyOfMap = newIntent.hashCode();
newIntent.putExtra(KEY_OF_MAP, keyOfMap);
sGlobalRefMap.put(keyOfMap, refMap);
}
}
示例7: switchFragment
import android.content.Intent; //导入方法依赖的package包/类
void switchFragment(@IdRes int itemId) {
Intent intent = getIntent();
// passing intent's extra to the fragment
Bundle extras = intent.getExtras();
Bundle arguments = (extras != null ? new Bundle(extras) : new Bundle());
switch (itemId) {
case R.id.nav_journal:
arguments.putString(TITLE, getString(R.string.Journal));
switchFragment(journalFragment, arguments);
break;
case R.id.nav_black_list:
arguments.putString(TITLE, getString(R.string.Black_list));
arguments.putInt(CONTACT_TYPE, Contact.TYPE_BLACK_LIST);
switchFragment(blackListFragment, arguments);
break;
case R.id.nav_white_list:
arguments.putString(TITLE, getString(R.string.White_list));
arguments.putInt(CONTACT_TYPE, Contact.TYPE_WHITE_LIST);
switchFragment(whiteListFragment, arguments);
break;
case R.id.nav_sms:
arguments.putString(TITLE, getString(R.string.Messaging));
switchFragment(smsFragment, arguments);
break;
case R.id.nav_settings:
arguments.putString(TITLE, getString(R.string.Settings));
switchFragment(settingsFragment, arguments);
break;
default:
arguments.putString(TITLE, getString(R.string.Information));
switchFragment(informationFragment, arguments);
break;
}
// remove used extras
intent.removeExtra(LIST_POSITION);
}
示例8: handleUninstallShortcutIntent
import android.content.Intent; //导入方法依赖的package包/类
private void handleUninstallShortcutIntent(Intent intent) {
Intent shortcut = intent.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT);
if (shortcut != null) {
ComponentName componentName = shortcut.resolveActivity(getPM());
if (componentName != null) {
Intent newShortcutIntent = new Intent();
newShortcutIntent.putExtra("_VA_|_uri_", shortcut);
newShortcutIntent.setClassName(getHostPkg(), Constants.SHORTCUT_PROXY_ACTIVITY_NAME);
newShortcutIntent.removeExtra(Intent.EXTRA_SHORTCUT_INTENT);
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, newShortcutIntent);
}
}
}
示例9: maybeRecordFallbackStats
import android.content.Intent; //导入方法依赖的package包/类
/**
* In the case where Chrome is called through the fallback mechanism from Instant Apps,
* record the amount of time the whole trip took and which UI took the user back to Chrome,
* if any.
* @param intent The current intent.
*/
private void maybeRecordFallbackStats(Intent intent) {
Long startTime = IntentUtils.safeGetLongExtra(intent, INSTANT_APP_START_TIME_EXTRA, 0);
if (startTime > 0) {
sFallbackIntentTimes.record(SystemClock.elapsedRealtime() - startTime);
intent.removeExtra(INSTANT_APP_START_TIME_EXTRA);
}
int callSource = IntentUtils.safeGetIntExtra(intent, BROWSER_LAUNCH_REASON, 0);
if (callSource > 0 && callSource < SOURCE_BOUNDARY) {
sFallbackCallSource.record(callSource);
intent.removeExtra(BROWSER_LAUNCH_REASON);
} else if (callSource >= SOURCE_BOUNDARY) {
Log.e(TAG, "Unexpected call source constant for Instant Apps: " + callSource);
}
}
示例10: safeRemoveExtra
import android.content.Intent; //导入方法依赖的package包/类
/**
* Just like {@link Intent#removeExtra(String)} but doesn't throw exceptions.
*/
public static void safeRemoveExtra(Intent intent, String name) {
try {
intent.removeExtra(name);
} catch (Throwable t) {
// Catches un-parceling exceptions.
Log.e(TAG, "removeExtra failed on intent " + intent);
}
}
示例11: initializeMainLayout
import android.content.Intent; //导入方法依赖的package包/类
@Override
public void initializeMainLayout(Intent argument) {
if (argument != null && argument.hasExtra(MainActivity.POSITION_ARGUMENT_KEY)) {
mInitialPosition = argument.getIntExtra(MainActivity.POSITION_ARGUMENT_KEY, NavigationUtils.POSITION_DASHBOARD);
if (mInitialPosition == NavigationUtils.POSITION_DASHBOARD) {
mFragment = new DashFragment();
} else if (mInitialPosition == NavigationUtils.POSITION_GRID) {
mFragment = new GridPagerFragment();
} else if (mInitialPosition == NavigationUtils.POSITION_LEAGUE) {
mFragment = new LeagueFragment();
} else if (mInitialPosition == NavigationUtils.POSITION_SETTING) {
Intent intent = new Intent(mMainView.getActivity(), SettingsActivity.class);
mMainView.getActivity().startActivity(intent);
}
argument.removeExtra(MainActivity.POSITION_ARGUMENT_KEY);
}
if (mFragment == null) {
mInitialPosition = NavigationUtils.POSITION_DASHBOARD;
mFragment = new DashFragment();
}
((AppCompatActivity) mMainView.getActivity()).getSupportFragmentManager().beginTransaction()
.add(mMainView.getMainLayoutId(), mFragment)
.commitAllowingStateLoss();
}
示例12: showDialogIf
import android.content.Intent; //导入方法依赖的package包/类
private void showDialogIf(Intent intent) {
if (intent.hasExtra("id")) {
id = intent.getExtras().getString("id");
intent.removeExtra("id");
Bundle args = new Bundle();
args.putString("id", id);
JoinGameDialogFragment fragment = new JoinGameDialogFragment();
fragment.setArguments(args);
fragment.show(getSupportFragmentManager(), "dialog");
}
}
示例13: showDialogIf
import android.content.Intent; //导入方法依赖的package包/类
private void showDialogIf(Intent intent) {
if (intent.hasExtra("id")) {
id = intent.getExtras().getString("id");
intent.removeExtra("id");
showDialog();
}
}
示例14: readIntent
import android.content.Intent; //导入方法依赖的package包/类
private void readIntent() {
Intent intent = getIntent();
long dateNoteCreated = intent.getLongExtra(INTENT_EXTRA_DATE_NOTE_CREATED, NOTE_INVALID_ID);
if (dateNoteCreated != NOTE_INVALID_ID) {
intent.removeExtra(INTENT_EXTRA_DATE_NOTE_CREATED);
getPresenter().openNote(dateNoteCreated);
}
}
示例15: cleanIntentPluginParams
import android.content.Intent; //导入方法依赖的package包/类
static final void cleanIntentPluginParams(Intent intent) {
// 防止 intent 攻击
try {
intent.removeExtra(IPluginManager.KEY_COMPATIBLE);
intent.removeExtra(IPluginManager.KEY_PLUGIN);
intent.removeExtra(IPluginManager.KEY_ACTIVITY);
} catch (Exception e) {
// ignore
}
}