當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。