|
|
@ -83,7 +83,7 @@ public class MicroPhotoContext {
|
|
|
|
public static String getPrimaryStoragePath(Context context) {
|
|
|
|
public static String getPrimaryStoragePath(Context context) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
StorageManager sm = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE);
|
|
|
|
StorageManager sm = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE);
|
|
|
|
Method getVolumePathsMethod = StorageManager.class.getMethod("getVolumePaths", (Class<?>[])null);
|
|
|
|
Method getVolumePathsMethod = StorageManager.class.getMethod("getVolumePaths", (Class<?>[]) null);
|
|
|
|
Object[] args = null;
|
|
|
|
Object[] args = null;
|
|
|
|
String[] paths = (String[]) getVolumePathsMethod.invoke(sm, args);
|
|
|
|
String[] paths = (String[]) getVolumePathsMethod.invoke(sm, args);
|
|
|
|
// first element in paths[] is primary storage path
|
|
|
|
// first element in paths[] is primary storage path
|
|
|
@ -99,7 +99,7 @@ public class MicroPhotoContext {
|
|
|
|
public static String getSecondaryStoragePath(Context context) {
|
|
|
|
public static String getSecondaryStoragePath(Context context) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
StorageManager sm = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE);
|
|
|
|
StorageManager sm = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE);
|
|
|
|
Method getVolumePathsMethod = StorageManager.class.getMethod("getVolumePaths", (Class<?>[])null);
|
|
|
|
Method getVolumePathsMethod = StorageManager.class.getMethod("getVolumePaths", (Class<?>[]) null);
|
|
|
|
Object[] args = null;
|
|
|
|
Object[] args = null;
|
|
|
|
String[] paths = (String[]) getVolumePathsMethod.invoke(sm, args);
|
|
|
|
String[] paths = (String[]) getVolumePathsMethod.invoke(sm, args);
|
|
|
|
// second element in paths[] is secondary storage path
|
|
|
|
// second element in paths[] is secondary storage path
|
|
|
@ -114,7 +114,7 @@ public class MicroPhotoContext {
|
|
|
|
public String getStorageState(Context context, String path) {
|
|
|
|
public String getStorageState(Context context, String path) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
StorageManager sm = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE);
|
|
|
|
StorageManager sm = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE);
|
|
|
|
Method getVolumeStateMethod = StorageManager.class.getMethod("getVolumeState", new Class[] {String.class});
|
|
|
|
Method getVolumeStateMethod = StorageManager.class.getMethod("getVolumeState", new Class[]{String.class});
|
|
|
|
String state = (String) getVolumeStateMethod.invoke(sm, path);
|
|
|
|
String state = (String) getVolumeStateMethod.invoke(sm, path);
|
|
|
|
return state;
|
|
|
|
return state;
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
@ -398,9 +398,9 @@ public class MicroPhotoContext {
|
|
|
|
intent.putExtra("reason", reason);
|
|
|
|
intent.putExtra("reason", reason);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
|
|
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
|
|
|
PendingIntent restartIntent = PendingIntent.getActivity(context, 0, intent, 0);
|
|
|
|
PendingIntent restartIntent = PendingIntent.getActivity(context, 100, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
|
|
|
AlarmManager mgr = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
|
|
|
|
AlarmManager mgr = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
|
|
|
mgr.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + delayedTimeMs, restartIntent);
|
|
|
|
mgr.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + ((delayedTimeMs > 0) ? delayedTimeMs : 10), restartIntent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void restartApp(Context context, String packageName, String reason) {
|
|
|
|
public static void restartApp(Context context, String packageName, String reason) {
|
|
|
|