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