| | |
| | | package com.android.app_base.manager; |
| | | |
| | | import android.app.Activity; |
| | | import android.app.AlarmManager; |
| | | import android.app.PendingIntent; |
| | | import android.content.ComponentName; |
| | | import android.content.Context; |
| | | import android.content.Intent; |
| | | import android.content.pm.PackageManager; |
| | | import android.text.TextUtils; |
| | | import android.util.Log; |
| | | |
| | | import androidx.annotation.NonNull; |
| | | import androidx.fragment.app.Fragment; |
| | | |
| | | import com.blankj.utilcode.util.ActivityUtils; |
| | | import com.blankj.utilcode.util.AppUtils; |
| | | |
| | | import java.util.Stack; |
| | | |
| | |
| | | return ActivityUtils.startActivity(intent); |
| | | } |
| | | |
| | | public void startActivityForName(String name) { |
| | | if(TextUtils.isEmpty(name))return; |
| | | try { |
| | | startActivity(Class.forName(name)); |
| | | } catch (ClassNotFoundException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | /** |
| | | * 结束当前Activity(堆栈中最后一个压入的) |
| | | */ |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 重启应用 |
| | | */ |
| | | public void restartApp() { |
| | | AppUtils.relaunchApp(); |
| | | } |
| | | public void restartApp(Context context) { |
| | | Intent intent = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName()); |
| | | intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); |
| | | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| | | startActivity(intent); |
| | | AppExit(); |
| | | } |
| | | } |