本文整理匯總了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);
}
}