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


Java Activity.getIntent方法代码示例

本文整理汇总了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));
    }
}
 
开发者ID:wangyupeng1-iri,项目名称:springreplugin,代码行数:33,代码来源:PluginLibraryInternalProxy.java

示例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();
  }
}
 
开发者ID:eviltnan,项目名称:kognitivo,代码行数:43,代码来源:MessengerUtils.java

示例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);
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:21,代码来源:Languages.java

示例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);
            }
        }
    }
}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:21,代码来源:WXContextManager.java

示例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)));
    }
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:29,代码来源:UIUtils.java

示例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;
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:27,代码来源:ActivityUtils.java

示例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);
    }
}
 
开发者ID:amikey,项目名称:DroidPlugin,代码行数:17,代码来源:PluginInstrumentation.java

示例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);
}
 
开发者ID:zzzkk2009,项目名称:react-native-leancloud-sdk,代码行数:16,代码来源:RNPushNotificationModule.java

示例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;
}
 
开发者ID:goutham106,项目名称:GmArchMvvm,代码行数:9,代码来源:ActivityLifecycle.java

示例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;
}
 
开发者ID:hshare,项目名称:MVPArmsTest1,代码行数:8,代码来源:ActivityLifecycle.java

示例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);
        }
    }
}
 
开发者ID:amikey,项目名称:DroidPlugin,代码行数:11,代码来源:PluginInstrumentation.java

示例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);
}
 
开发者ID:gregoreesmaa,项目名称:minu-poska-android,代码行数:28,代码来源:TextUtils.java

示例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");
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:14,代码来源:WebViewActivity.java

示例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);
}
 
开发者ID:xiaobailong24,项目名称:MVVMArms,代码行数:28,代码来源:ActivityLifecycle.java

示例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);
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:10,代码来源:DynamicLanguage.java


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