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


Java Activity.startActivity方法代码示例

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


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

示例1: showAdFull

import android.app.Activity; //导入方法依赖的package包/类
private void showAdFull(App app, @Nullable Activity activity) {
    Context context = builder.getContext();

    long lastShown = SharedPrefsUtils.getLastShown(context);
    long diff = System.currentTimeMillis() - lastShown;
    if (diff < builder.getShowFrequency()) {
        return;
    }

    Intent intent = new Intent(builder.getContext(), AdSimasFullActivity.class)
            .putExtra(AdSimasFullActivity.EXTRA_APP, app)
            .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    if (activity != null) {
        activity.startActivity(intent);
        activity.overridePendingTransition(R.anim.fade_in, 0);
    } else {
        context.startActivity(intent);
    }

}
 
开发者ID:leosimas,项目名称:AdSimasTeam,代码行数:22,代码来源:AdSimasTeam.java

示例2: gotoPlayStore

import android.app.Activity; //导入方法依赖的package包/类
/**
 * Go to Google Play app
 *
 * @param context - android context
 * @param appId   - an application id
 */
public static void gotoPlayStore(Activity context, String appId) {
    DLog.d(TAG, "gotoPlayStore() called with: context = [" + context + "], appId = [" + appId + "]");
    Uri uri = Uri.parse(String.format("market://details?id=%s", appId));
    Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
    // To count with Play market backstack, After pressing back button,
    // to taken back to our application, we need to add following flags to intent.
    goToMarket.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
    try {
        context.startActivity(goToMarket);
    } catch (Exception e) {
        DLog.e(e);
        try {
            Uri link = Uri.parse("http://play.google.com/store/apps/details?id=" + appId);
            Intent intent = new Intent(Intent.ACTION_VIEW, link);
            context.startActivity(intent);
        } catch (Exception e2) {
            DLog.e(e2);
        }
    }
}
 
开发者ID:tranleduy2000,项目名称:text_converter,代码行数:27,代码来源:StoreUtil.java

示例3: launchInstance

import android.app.Activity; //导入方法依赖的package包/类
public static void launchInstance(Activity activity, Intent originalIntent) {
    Intent intent = new Intent();
    intent.setClass(activity, UpgradeActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
    intent.putExtra(UpgradeActivity.EXTRA_INTENT_TO_REFIRE, originalIntent);
    activity.startActivity(intent);
    activity.overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:9,代码来源:UpgradeActivity.java

示例4: startNewActivity

import android.app.Activity; //导入方法依赖的package包/类
public static void startNewActivity(Activity activity, Class<?> cls, boolean isFinish) {
    Intent intent = new Intent(activity, cls);
    activity.startActivity(intent);

    if (isFinish) {
        activity.finish();
    }
}
 
开发者ID:nhocga1995s,项目名称:MyCalendar,代码行数:9,代码来源:FunctionHelper.java

示例5: start

import android.app.Activity; //导入方法依赖的package包/类
/**
     * @param context      activity
     * @param positionData bean
     * @param imageView    imageView
     */
    public static void start(Activity context, SubjectsBean positionData, ImageView imageView) {
        Intent intent = new Intent(context, TestActivity.class);
        intent.putExtra("bean", positionData);
//        ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(context,
//                        imageView, CommonUtils.getString(R.string.transition_movie_img));//与xml文件对应

//        ActivityOptionsCompat options = ActivityOptionsCompat.makeBasic();// 右边进右边出
//        ActivityCompat.startActivity(context, intent, options.toBundle());
        context.startActivity(intent);
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:TestActivity.java

示例6: handleNormalLinked

import android.app.Activity; //导入方法依赖的package包/类
private boolean handleNormalLinked(String url){
    if (url.startsWith(WebView.SCHEME_TEL) || url.startsWith("sms:") || url.startsWith(WebView.SCHEME_MAILTO)) {
        try {
            Activity mActivity=null;
            if((mActivity=mWeakReference.get())==null)
                return false;
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse(url));
            mActivity.startActivity(intent);
        } catch (ActivityNotFoundException ignored) {
        }
        return true;
    }
    return false;
}
 
开发者ID:Justson,项目名称:AgentWebX5,代码行数:16,代码来源:DefaultWebClient.java

示例7: openURL

import android.app.Activity; //导入方法依赖的package包/类
/**
 * Starts a corresponding external activity for the given URL.
 *
 * For example, if the URL is "https://www.facebook.com", the system browser will be opened,
 * or the "choose application" dialog will be shown.
 *
 * @param url the URL to open
 */
@ReactMethod
public void openURL(String url, Promise promise) {
  if (url == null || url.isEmpty()) {
    promise.reject(new JSApplicationIllegalArgumentException("Invalid URL: " + url));
    return;
  }

  try {
    Activity currentActivity = getCurrentActivity();
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));

    String selfPackageName = getReactApplicationContext().getPackageName();
    ComponentName componentName = intent.resolveActivity(
      getReactApplicationContext().getPackageManager());
    String otherPackageName = (componentName != null ? componentName.getPackageName() : "");

    // If there is no currentActivity or we are launching to a different package we need to set
    // the FLAG_ACTIVITY_NEW_TASK flag
    if (currentActivity == null || !selfPackageName.equals(otherPackageName)) {
      intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    }

    if (currentActivity != null) {
      currentActivity.startActivity(intent);
    } else {
      getReactApplicationContext().startActivity(intent);
    }

    promise.resolve(true);
  } catch (Exception e) {
    promise.reject(new JSApplicationIllegalArgumentException(
        "Could not open URL '" + url + "': " + e.getMessage()));
  }
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:43,代码来源:IntentModule.java

示例8: startActivity

import android.app.Activity; //导入方法依赖的package包/类
/**
 * @param activity
 * @param bundle
 */
public static void startActivity(Activity mContext, Class<? extends Activity> activity, Bundle bundle) {
    if (mContext == null) {
        return;
    }
    Intent intent = new Intent(mContext, activity);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
            | Intent.FLAG_ACTIVITY_CLEAR_TOP);
    if (bundle != null) {
        intent.putExtras(bundle);
    }
    mContext.startActivity(intent);
}
 
开发者ID:AriesHoo,项目名称:UIWidget,代码行数:17,代码来源:AppUtil.java

示例9: moreApp

import android.app.Activity; //导入方法依赖的package包/类
public static void moreApp(Activity mainActivity) {
    Uri uri = Uri.parse("market://search?q=pub:Trần Lê Duy");
    Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
    // To count with Play market backstack, After pressing back button,
    // to taken back to our application, we need to add following flags to intent.
    goToMarket.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
    try {
        mainActivity.startActivity(goToMarket);
    } catch (ActivityNotFoundException e) {
        mainActivity.startActivity(new Intent(Intent.ACTION_VIEW,
                Uri.parse("http://play.google.com/store/search?q=pub:Trần Lê Duy")));
    }
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:14,代码来源:StoreUtil.java

示例10: openFileByUri

import android.app.Activity; //导入方法依赖的package包/类
/** 使用系统API打开文件 */
public static void openFileByUri(Activity activityFrom, String url) {
    Intent intent = new Intent();
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);//If set, this activity will become the start of a new task on this history stack.
    intent.setAction(Intent.ACTION_VIEW);// it is the generic action you can use on a piece of data to get the most reasonable合适的 thing to occur
    intent.addCategory(Intent.CATEGORY_DEFAULT);//Set if the activity should be an option选项 for the default action to perform on a piece of data
    intent.setDataAndType(Uri.parse(url), getMimeTypeFromUrl(url));//Set the data for the intent along with an explicit指定的、明确的 MIME data type
    activityFrom.startActivity(intent);
}
 
开发者ID:xm0625,项目名称:VBrowser-Android,代码行数:10,代码来源:IntentUtil.java

示例11: navigateToExample

import android.app.Activity; //导入方法依赖的package包/类
@ReactMethod
void navigateToExample() {
    Activity activity = getCurrentActivity();
    if (activity != null) {
        Intent intent = new Intent(activity, ExampleActivity.class);
        activity.startActivity(intent);
    }
}
 
开发者ID:petterh,项目名称:react-native-android-activity,代码行数:9,代码来源:ActivityStarterModule.java

示例12: openUserInfoByUid

import android.app.Activity; //导入方法依赖的package包/类
/**
 * 通过uid打开个人资料界面。
 * 
 * @param activity
 * @param uid   用户ID
 */
public static void openUserInfoByUid(Activity activity,String uid){
    if(activity==null){
        return;
    }
    Intent intent=new Intent();
    intent.setAction(Intent.ACTION_VIEW);
    intent.addCategory("android.intent.category.DEFAULT");
    intent.setData(Uri.parse("sinaweibo://userinfo?uid="+uid));
    activity.startActivity(intent);
}
 
开发者ID:ligongzai,项目名称:QianXun,代码行数:17,代码来源:ActivityInvokeAPI.java

示例13: Meizu

import android.app.Activity; //导入方法依赖的package包/类
public static void Meizu(Activity activity) {
    Intent intent = new Intent("com.meizu.safe.security.SHOW_APPSEC");
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent.putExtra("packageName", BuildConfig.APPLICATION_ID);
    activity.startActivity(intent);
}
 
开发者ID:xmlxin,项目名称:ReplyMessage,代码行数:7,代码来源:JumpPermissionManagement.java

示例14: newIntent

import android.app.Activity; //导入方法依赖的package包/类
public static void newIntent(Activity activity, Bundle bundle) {
    Intent intent = new Intent(activity, DisplayActivity.class);
    intent.putExtras(bundle);
    activity.startActivity(intent);
}
 
开发者ID:miaoyongjun,项目名称:MVideo,代码行数:6,代码来源:DisplayActivity.java

示例15: launchActivity

import android.app.Activity; //导入方法依赖的package包/类
public static void launchActivity(Activity context){
    context.startActivity(new Intent(context, ChannelActivity.class));
    context.overridePendingTransition(R.anim.fade_entry, R.anim.hold);
}
 
开发者ID:lai233333,项目名称:MyDemo,代码行数:5,代码来源:ChannelActivity.java


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