本文整理汇总了Java中android.app.Activity.getIntent方法的典型用法代码示例。如果您正苦于以下问题:Java Activity.getIntent方法的具体用法?Java Activity.getIntent怎么用?Java Activity.getIntent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.app.Activity
的用法示例。
在下文中一共展示了Activity.getIntent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleActivityCreateBefore
import android.app.Activity; //导入方法依赖的package包/类
/**
* @hide 内部方法,插件框架使用
* 插件的Activity的onCreate调用前调用此方法
* @param activity
* @param savedInstanceState
*/
public void handleActivityCreateBefore(Activity activity, Bundle savedInstanceState) {
if (LOG) {
LogDebug.d(PLUGIN_TAG, "activity create before: " + activity.getClass().getName() + " this=" + activity.hashCode() + " taskid=" + activity.getTaskId());
}
// 对FragmentActivity做特殊处理
if (savedInstanceState != null) {
//
savedInstanceState.setClassLoader(activity.getClassLoader());
//
try {
savedInstanceState.remove("android:support:fragments");
} catch (Throwable e) {
if (LOGR) {
LogRelease.e(PLUGIN_TAG, "a.c.b1: " + e.getMessage(), e);
}
}
}
// 对FragmentActivity做特殊处理
Intent intent = activity.getIntent();
if (intent != null) {
intent.setExtrasClassLoader(activity.getClassLoader());
activity.setTheme(getThemeId(activity, intent));
}
}
示例2: finishShareToMessenger
import android.app.Activity; //导入方法依赖的package包/类
/**
* Finishes the activity and returns the media item the user picked to Messenger.
*
* @param activity the activity that received the original intent from Messenger
* @param shareToMessengerParams parameters for what to share
*/
public static void finishShareToMessenger(
Activity activity,
ShareToMessengerParams shareToMessengerParams) {
Intent originalIntent = activity.getIntent();
Set<String> categories = originalIntent.getCategories();
if (categories == null) {
// This shouldn't happen.
activity.setResult(Activity.RESULT_CANCELED, null);
activity.finish();
return;
}
if (categories.contains(ORCA_THREAD_CATEGORY_20150314)) {
Bundle appLinkExtras = AppLinks.getAppLinkExtras(originalIntent);
Intent resultIntent = new Intent();
if (categories.contains(ORCA_THREAD_CATEGORY_20150314)) {
resultIntent.putExtra(EXTRA_PROTOCOL_VERSION, MessengerUtils.PROTOCOL_VERSION_20150314);
String threadToken = appLinkExtras.getString(MessengerUtils.EXTRA_THREAD_TOKEN_KEY);
resultIntent.putExtra(EXTRA_THREAD_TOKEN_KEY, threadToken);
} else {
throw new RuntimeException(); // Can't happen.
}
resultIntent.setDataAndType(shareToMessengerParams.uri, shareToMessengerParams.mimeType);
resultIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
resultIntent.putExtra(EXTRA_APP_ID, FacebookSdk.getApplicationId());
resultIntent.putExtra(EXTRA_METADATA, shareToMessengerParams.metaData);
resultIntent.putExtra(EXTRA_EXTERNAL_URI, shareToMessengerParams.externalUri);
activity.setResult(Activity.RESULT_OK, resultIntent);
activity.finish();
} else {
// This shouldn't happen.
activity.setResult(Activity.RESULT_CANCELED, null);
activity.finish();
}
}
示例3: forceChangeLanguage
import android.app.Activity; //导入方法依赖的package包/类
/**
* Force reload the {@link Activity to make language changes take effect.}
*
* @param activity the {@code Activity} to force reload
*/
public static void forceChangeLanguage(Activity activity) {
if (Build.VERSION.SDK_INT >= 24) {
Utils.debugLog(TAG, "Languages.forceChangeLanguage() ignored on >= android-24");
return;
}
Intent intent = activity.getIntent();
if (intent == null) { // when launched as LAUNCHER
return;
}
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
activity.finish();
activity.overridePendingTransition(0, 0);
activity.startActivity(intent);
activity.overridePendingTransition(0, 0);
}
示例4: receiveBack
import android.app.Activity; //导入方法依赖的package包/类
public void receiveBack(Activity activity) {
if (activity != null) {
if (callback != null) {
Intent intent = activity.getIntent();
if (intent != null) {
String params = intent.getStringExtra("params");
JSONObject jsonObject = null;
if (!TextUtils.isEmpty(params)) {
try {
jsonObject = JSON.parseObject(params);
} catch (Exception e) {
UWLog.e("WXC", e.getMessage());
}
}
String backTag = intent.getStringExtra("backTag");
callback.callBack(backTag, jsonObject);
}
}
}
}
示例5: 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)));
}
}
示例6: checkInputExist
import android.app.Activity; //导入方法依赖的package包/类
public static boolean checkInputExist(Activity activity) {
Intent intent = activity.getIntent();
if (intent == null) {
return false;
}
Bundle extras = intent.getExtras();
String action = intent.getAction();
if (extras == null || action == null) {
return false;
}
if (Intent.ACTION_SEND_MULTIPLE.equals(action)) {
if (extras.containsKey(Intent.EXTRA_STREAM)) {
return true;
}
}
if (Intent.ACTION_SEND.equals(action)) {
if (extras.containsKey(Intent.EXTRA_STREAM) || extras.containsKey(Intent.EXTRA_TEXT)) {
return true;
}
}
return false;
}
示例7: onActivityOnNewIntent
import android.app.Activity; //导入方法依赖的package包/类
private void onActivityOnNewIntent(Activity activity, Intent intent) throws RemoteException {
//
try {
Intent targetIntent = activity.getIntent();
if (targetIntent != null) {
ActivityInfo targetInfo = targetIntent.getParcelableExtra(Env.EXTRA_TARGET_INFO);
ActivityInfo stubInfo = targetIntent.getParcelableExtra(Env.EXTRA_STUB_INFO);
if (targetInfo != null && stubInfo != null) {
RunningActivities.onActivtyOnNewIntent(activity, targetInfo, stubInfo, intent);
PluginManager.getInstance().onActivtyOnNewIntent(stubInfo, targetInfo, intent);
}
}
} catch (Exception e) {
Log.i(TAG, "onActivityCreated fail", e);
}
}
示例8: getInitialNotification
import android.app.Activity; //导入方法依赖的package包/类
@ReactMethod
public void getInitialNotification(Promise promise) {
WritableMap params = Arguments.createMap();
Activity activity = getCurrentActivity();
if (activity != null) {
Intent intent = activity.getIntent();
Bundle bundle = intent.getBundleExtra("notification");
if (bundle != null) {
bundle.putBoolean("foreground", false);
String bundleString = mJsDelivery.convertJSON(bundle);
params.putString("dataJSON", bundleString);
}
}
promise.resolve(params);
}
示例9: fetchActivityDelegate
import android.app.Activity; //导入方法依赖的package包/类
private ActivityDelegate fetchActivityDelegate(Activity activity) {
ActivityDelegate activityDelegate = null;
if (activity instanceof IActivity && activity.getIntent() != null) {
activity.getIntent().setExtrasClassLoader(getClass().getClassLoader());
activityDelegate = activity.getIntent().getParcelableExtra(ActivityDelegate.ACTIVITY_DELEGATE);
}
return activityDelegate;
}
示例10: fetchActivityDelegate
import android.app.Activity; //导入方法依赖的package包/类
private ActivityDelegate fetchActivityDelegate(Activity activity) {
ActivityDelegate activityDelegate = null;
if (activity instanceof IActivity && activity.getIntent() != null) {
activityDelegate = activity.getIntent().getParcelableExtra(ActivityDelegate.ACTIVITY_DELEGATE);
}
return activityDelegate;
}
示例11: onActivityDestory
import android.app.Activity; //导入方法依赖的package包/类
private void onActivityDestory(Activity activity) throws RemoteException {
Intent targetIntent = activity.getIntent();
if (targetIntent != null) {
ActivityInfo targetInfo = targetIntent.getParcelableExtra(Env.EXTRA_TARGET_INFO);
ActivityInfo stubInfo = targetIntent.getParcelableExtra(Env.EXTRA_STUB_INFO);
if (targetInfo != null && stubInfo != null) {
PluginManager.getInstance().onActivityDestory(stubInfo, targetInfo);
}
}
}
示例12: updateLanguage
import android.app.Activity; //导入方法依赖的package包/类
public static void updateLanguage(Activity a) {
if (a == null)
return;
Context context = a.getApplicationContext();
Locale l;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
l = context.getResources().getConfiguration().getLocales().get(0);
else l = context.getResources().getConfiguration().locale;
String languageSelection = DataUtils.getLanguage(context);
if (l != null && l.getLanguage().equalsIgnoreCase(languageSelection))
return;
Configuration cfg = new Configuration();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
cfg.setLocale(new Locale(languageSelection));
else cfg.locale = new Locale(languageSelection);
context.getResources().updateConfiguration(cfg, null);
// Restart activity and notifications
a.finish();
Intent intent = a.getIntent();
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
LessonNotificationScheduler.updateBroadcastReceiver(context);
HomeworkNotificationScheduler.updateBroadcastReceiver(context);
}
示例13: WebViewActivity
import android.app.Activity; //导入方法依赖的package包/类
public WebViewActivity(Activity activity) {
this.e = activity;
Intent intent = activity.getIntent();
if (intent != null) {
Uri data = intent.getData();
if (!(data == null || TextUtils.isEmpty(data.getQueryParameter("key")))) {
this.d = data.getQueryParameter("key").trim();
}
if (!TextUtils.isEmpty(intent.getStringExtra("mw_key"))) {
this.d = intent.getStringExtra("mw_key");
}
}
}
示例14: onActivityCreated
import android.app.Activity; //导入方法依赖的package包/类
@Override
public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
Timber.w("%s ---> onActivityCreated", activity);
//如果 intent 包含了此字段,并且为 true 说明不加入到 list 进行统一管理
boolean isNotAdd = false;
if (activity.getIntent() != null) {
isNotAdd = activity.getIntent().getBooleanExtra(AppManager.IS_NOT_ADD_ACTIVITY_LIST, false);
}
if (!isNotAdd) {
mAppManager.addActivity(activity);
}
//配置ActivityDelegate
if (activity instanceof IActivity && activity.getIntent() != null) {
ActivityDelegate activityDelegate = fetchActivityDelegate(activity);
if (activityDelegate == null) {
activityDelegate = new ActivityDelegateImpl(activity);
activity.getIntent().putExtra(ActivityDelegate.ACTIVITY_DELEGATE, activityDelegate);
}
activityDelegate.onCreate(savedInstanceState);
}
// 给每个Activity配置Fragment的监听,Activity可以通过 {@link IActivity#useFragment()} 设置是否使用监听
registerFragmentCallbacks(activity);
}
示例15: onResume
import android.app.Activity; //导入方法依赖的package包/类
public void onResume(Activity activity) {
if (!currentLocale.equals(getSelectedLocale(activity))) {
Intent intent = activity.getIntent();
activity.finish();
OverridePendingTransition.invoke(activity);
activity.startActivity(intent);
OverridePendingTransition.invoke(activity);
}
}