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