Example usage for android.content Intent getFlags

List of usage examples for android.content Intent getFlags

Introduction

In this page you can find the example usage for android.content Intent getFlags.

Prototype

public @Flags int getFlags() 

Source Link

Document

Retrieve any special flags associated with this intent.

Usage

From source file:me.myatminsoe.myansms.SmsReceiver.java

/**
 * Update new message {@link Notification}.
 *
 * @param context {@link Context}//from  ww w. j  a  v a2 s  .  co m
 * @param text    text of the last assumed unread message
 * @return number of unread messages
 */
static int updateNewMessageNotification(final Context context, final String text) {
    final NotificationManager mNotificationMgr = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    final boolean enableNotifications = prefs.getBoolean(PreferencesActivity.PREFS_NOTIFICATION_ENABLE, true);
    final boolean privateNotification = prefs.getBoolean(PreferencesActivity.PREFS_NOTIFICATION_PRIVACY, false);
    final boolean showPhoto = !privateNotification
            && prefs.getBoolean(PreferencesActivity.PREFS_CONTACT_PHOTO, true);
    if (!enableNotifications) {
        mNotificationMgr.cancelAll();
        Log.d(TAG, "no notification needed!");
    }
    final int[] status = getUnread(context.getContentResolver(), text);
    final int l = status[ID_COUNT];
    final int tid = status[ID_TID];

    // FIXME l is always -1..
    if (l < 0) {
        return l;
    }

    if (enableNotifications && (text != null || l == 0)) {
        mNotificationMgr.cancel(NOTIFICATION_ID_NEW);
    }
    Uri uri;
    PendingIntent pIntent;
    if (l == 0) {
        final Intent i = new Intent(context, ConversationListActivity.class);
        // add pending intent
        i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        pIntent = PendingIntent.getActivity(context, 0, i, PendingIntent.FLAG_CANCEL_CURRENT);
    } else {
        final NotificationCompat.Builder nb = new NotificationCompat.Builder(context);
        boolean showNotification = true;
        Intent i;
        if (tid >= 0) {
            uri = Uri.parse(MessageListActivity.URI + tid);
            i = new Intent(Intent.ACTION_VIEW, uri, context, MessageListActivity.class);
            pIntent = PendingIntent.getActivity(context, 0, i, PendingIntent.FLAG_UPDATE_CURRENT);

            if (enableNotifications) {
                final Conversation conv = Conversation.getConversation(context, tid, true);
                if (conv != null) {
                    String a;
                    if (privateNotification) {
                        if (l == 1) {
                            a = context.getString(R.string.new_message_);
                        } else {
                            a = context.getString(R.string.new_messages_);
                        }
                    } else {
                        a = conv.getContact().getDisplayName();
                    }
                    showNotification = true;
                    nb.setSmallIcon(PreferencesActivity.getNotificationIcon(context));
                    nb.setTicker(a);
                    nb.setWhen(lastUnreadDate);
                    if (l == 1) {
                        String body;
                        if (privateNotification) {
                            body = context.getString(R.string.new_message);
                        } else {
                            body = lastUnreadBody;
                        }
                        if (body == null) {
                            body = context.getString(R.string.mms_conversation);
                        }
                        nb.setContentTitle(a);
                        nb.setContentText(body);
                        nb.setContentIntent(pIntent);
                        // add long text
                        nb.setStyle(new NotificationCompat.BigTextStyle().bigText(body));

                        // add actions
                        Intent nextIntent = new Intent(NotificationBroadcastReceiver.ACTION_MARK_READ);
                        nextIntent.putExtra(NotificationBroadcastReceiver.EXTRA_MURI, uri.toString());
                        PendingIntent nextPendingIntent = PendingIntent.getBroadcast(context, 0, nextIntent,
                                PendingIntent.FLAG_UPDATE_CURRENT);

                        nb.addAction(R.drawable.ic_done_24dp, context.getString(R.string.mark_read_),
                                nextPendingIntent);
                        nb.addAction(R.drawable.ic_reply_24dp, context.getString(R.string.reply), pIntent);
                    } else {
                        nb.setContentTitle(a);
                        nb.setContentText(context.getString(R.string.new_messages, l));
                        nb.setContentIntent(pIntent);
                    }
                    if (showPhoto // just for the speeeeed
                            && Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
                        try {
                            conv.getContact().update(context, false, true);
                        } catch (NullPointerException e) {
                            Log.e(TAG, "updating contact failed", e);
                        }
                        Drawable d = conv.getContact().getAvatar(context, null);
                        if (d instanceof BitmapDrawable) {
                            Bitmap bitmap = ((BitmapDrawable) d).getBitmap();
                            // 24x24 dp according to android iconography  ->
                            // http://developer.android.com/design/style/iconography.html#notification
                            int px = Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 64,
                                    context.getResources().getDisplayMetrics()));
                            nb.setLargeIcon(Bitmap.createScaledBitmap(bitmap, px, px, false));
                        }
                    }
                }
            }
        } else {
            uri = Uri.parse(MessageListActivity.URI);
            i = new Intent(Intent.ACTION_VIEW, uri, context, ConversationListActivity.class);
            pIntent = PendingIntent.getActivity(context, 0, i, PendingIntent.FLAG_UPDATE_CURRENT);

            if (enableNotifications) {
                showNotification = true;
                nb.setSmallIcon(PreferencesActivity.getNotificationIcon(context));
                nb.setTicker(context.getString(R.string.new_messages_));
                nb.setWhen(lastUnreadDate);
                nb.setContentTitle(context.getString(R.string.new_messages_));
                nb.setContentText(context.getString(R.string.new_messages, l));
                nb.setContentIntent(pIntent);
                nb.setNumber(l);
            }
        }
        // add pending intent
        i.setFlags(i.getFlags() | Intent.FLAG_ACTIVITY_NEW_TASK);

        if (enableNotifications && showNotification) {
            int[] ledFlash = PreferencesActivity.getLEDflash(context);
            nb.setLights(PreferencesActivity.getLEDcolor(context), ledFlash[0], ledFlash[1]);
            final SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(context);
            if (text != null) {
                final boolean vibrate = p.getBoolean(PreferencesActivity.PREFS_VIBRATE, false);
                final String s = p.getString(PreferencesActivity.PREFS_SOUND, null);
                Uri sound;
                if (s == null || s.length() <= 0) {
                    sound = null;
                } else {
                    sound = Uri.parse(s);
                }
                if (vibrate) {
                    final long[] pattern = PreferencesActivity.getVibratorPattern(context);
                    if (pattern.length == 1 && pattern[0] == 0) {
                        nb.setDefaults(Notification.DEFAULT_VIBRATE);
                    } else {
                        nb.setVibrate(pattern);
                    }
                }
                nb.setSound(sound);
            }
        }

        mNotificationMgr.cancel(NOTIFICATION_ID_NEW);
        if (enableNotifications && showNotification) {
            try {
                mNotificationMgr.notify(NOTIFICATION_ID_NEW, nb.getNotification());
            } catch (IllegalArgumentException e) {

            }
        }
    }
    //noinspection ConstantConditions
    return l;
}

From source file:com.klinker.android.launcher.launcher3.Launcher.java

@Override
protected void onNewIntent(Intent intent) {
    long startTime = 0;
    if (DEBUG_RESUME_TIME) {
        startTime = System.currentTimeMillis();
    }/*w  w w  . java 2  s  .  c o  m*/
    super.onNewIntent(intent);

    // Close the menu
    if (Intent.ACTION_MAIN.equals(intent.getAction())) {
        final boolean alreadyOnHome = mHasFocus && ((intent.getFlags()
                & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);

        if (mLauncherDrawer.isDrawerOpen(Gravity.LEFT)) {
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    mLauncherDrawer.closeDrawer(Gravity.LEFT);
                }
            }, 300);

            return;
        } else if (mLauncherDrawer.isDrawerOpen(Gravity.RIGHT)) {
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    mLauncherDrawer.closeDrawer(Gravity.RIGHT);
                }
            }, 300);

            return;
        } else if (!isAllAppsVisible() && alreadyOnHome && mWorkspace.getCurrentPage() == 0
                && !mWorkspace.isInOverviewMode()) {
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    GestureUtils.runGesture(Launcher.this, Launcher.this, AppSettings.HOME_BUTTON);
                }
            }, 300);

            return;
        }

        // also will cancel mWaitingForResult.
        closeSystemDialogs();

        if (mWorkspace == null) {
            // Can be cases where mWorkspace is null, this prevents a NPE
            return;
        }
        Folder openFolder = mWorkspace.getOpenFolder();
        // In all these cases, only animate if we're already on home
        mWorkspace.exitWidgetResizeMode();

        boolean moveToDefaultScreen = mLauncherCallbacks != null
                ? mLauncherCallbacks.shouldMoveToDefaultScreenOnHomeIntent()
                : true;
        if (alreadyOnHome && mState == State.WORKSPACE && !mWorkspace.isTouchActive() && openFolder == null
                && moveToDefaultScreen) {
            mWorkspace.moveToDefaultScreen(true);
        }

        closeFolder();
        exitSpringLoadedDragMode();

        // If we are already on home, then just animate back to the workspace,
        // otherwise, just wait until onResume to set the state back to Workspace
        if (alreadyOnHome) {
            showWorkspace(true);
        } else {
            mOnResumeState = State.WORKSPACE;
        }

        final View v = getWindow().peekDecorView();
        if (v != null && v.getWindowToken() != null) {
            InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
        }

        // Reset the apps view
        if (!alreadyOnHome && mAppsView != null) {
            mAppsView.scrollToTop();
        }

        // Reset the widgets view
        if (!alreadyOnHome && mWidgetsView != null) {
            mWidgetsView.scrollToTop();
        }

        if (mLauncherCallbacks != null) {
            mLauncherCallbacks.onHomeIntent();
        }
    }

    if (DEBUG_RESUME_TIME) {
        Log.d(TAG, "Time spent in onNewIntent: " + (System.currentTimeMillis() - startTime));
    }

    if (mLauncherCallbacks != null) {
        mLauncherCallbacks.onNewIntent(intent);
    }
}

From source file:de.ub0r.android.smsdroid.SmsReceiver.java

/**
 * Update new message {@link Notification}.
 *
 * @param context {@link Context}//from   ww w .  ja v a 2 s.c  om
 * @param text    text of the last assumed unread message
 * @return number of unread messages
 */
static int updateNewMessageNotification(final Context context, final String text) {
    Log.d(TAG, "updNewMsgNoti(", context, ",", text, ")");
    final NotificationManager mNotificationMgr = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    final boolean enableNotifications = prefs.getBoolean(PreferencesActivity.PREFS_NOTIFICATION_ENABLE, true);
    final boolean privateNotification = prefs.getBoolean(PreferencesActivity.PREFS_NOTIFICATION_PRIVACY, false);
    final boolean showPhoto = !privateNotification
            && prefs.getBoolean(PreferencesActivity.PREFS_CONTACT_PHOTO, true);
    if (!enableNotifications) {
        mNotificationMgr.cancelAll();
        Log.d(TAG, "no notification needed!");
    }
    final int[] status = getUnread(context.getContentResolver(), text);
    final int l = status[ID_COUNT];
    final int tid = status[ID_TID];

    // FIXME l is always -1..
    Log.d(TAG, "l: ", l);
    if (l < 0) {
        return l;
    }

    if (enableNotifications && (text != null || l == 0)) {
        mNotificationMgr.cancel(NOTIFICATION_ID_NEW);
    }
    Uri uri;
    PendingIntent pIntent;
    if (l == 0) {
        final Intent i = new Intent(context, ConversationListActivity.class);
        // add pending intent
        i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        pIntent = PendingIntent.getActivity(context, 0, i, PendingIntent.FLAG_CANCEL_CURRENT);
    } else {
        final NotificationCompat.Builder nb = new NotificationCompat.Builder(context);
        boolean showNotification = true;
        Intent i;
        if (tid >= 0) {
            uri = Uri.parse(MessageListActivity.URI + tid);
            i = new Intent(Intent.ACTION_VIEW, uri, context, MessageListActivity.class);
            pIntent = PendingIntent.getActivity(context, 0, i, PendingIntent.FLAG_UPDATE_CURRENT);

            if (enableNotifications) {
                final Conversation conv = Conversation.getConversation(context, tid, true);
                if (conv != null) {
                    String a;
                    if (privateNotification) {
                        if (l == 1) {
                            a = context.getString(R.string.new_message_);
                        } else {
                            a = context.getString(R.string.new_messages_);
                        }
                    } else {
                        a = conv.getContact().getDisplayName();
                    }
                    showNotification = true;
                    nb.setSmallIcon(PreferencesActivity.getNotificationIcon(context));
                    nb.setTicker(a);
                    nb.setWhen(lastUnreadDate);
                    if (l == 1) {
                        String body;
                        if (privateNotification) {
                            body = context.getString(R.string.new_message);
                        } else {
                            body = lastUnreadBody;
                        }
                        if (body == null) {
                            body = context.getString(R.string.mms_conversation);
                        }
                        nb.setContentTitle(a);
                        nb.setContentText(body);
                        nb.setContentIntent(pIntent);
                        // add long text
                        nb.setStyle(new NotificationCompat.BigTextStyle().bigText(body));

                        // add actions
                        Intent nextIntent = new Intent(NotificationBroadcastReceiver.ACTION_MARK_READ);
                        nextIntent.putExtra(NotificationBroadcastReceiver.EXTRA_MURI, uri.toString());
                        PendingIntent nextPendingIntent = PendingIntent.getBroadcast(context, 0, nextIntent,
                                PendingIntent.FLAG_UPDATE_CURRENT);

                        nb.addAction(R.drawable.ic_menu_mark, context.getString(R.string.mark_read_),
                                nextPendingIntent);
                        nb.addAction(R.drawable.ic_menu_compose, context.getString(R.string.reply), pIntent);
                    } else {
                        nb.setContentTitle(a);
                        nb.setContentText(context.getString(R.string.new_messages, l));
                        nb.setContentIntent(pIntent);
                    }
                    if (showPhoto // just for the speeeeed
                            && Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
                        try {
                            conv.getContact().update(context, false, true);
                        } catch (NullPointerException e) {
                            Log.e(TAG, "updating contact failed", e);
                        }
                        Drawable d = conv.getContact().getAvatar(context, null);
                        if (d instanceof BitmapDrawable) {
                            Bitmap bitmap = ((BitmapDrawable) d).getBitmap();
                            // 24x24 dp according to android iconography  ->
                            // http://developer.android.com/design/style/iconography.html#notification
                            int px = Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 64,
                                    context.getResources().getDisplayMetrics()));
                            nb.setLargeIcon(Bitmap.createScaledBitmap(bitmap, px, px, false));
                        }
                    }
                }
            }
        } else {
            uri = Uri.parse(MessageListActivity.URI);
            i = new Intent(Intent.ACTION_VIEW, uri, context, ConversationListActivity.class);
            pIntent = PendingIntent.getActivity(context, 0, i, PendingIntent.FLAG_UPDATE_CURRENT);

            if (enableNotifications) {
                showNotification = true;
                nb.setSmallIcon(PreferencesActivity.getNotificationIcon(context));
                nb.setTicker(context.getString(R.string.new_messages_));
                nb.setWhen(lastUnreadDate);
                nb.setContentTitle(context.getString(R.string.new_messages_));
                nb.setContentText(context.getString(R.string.new_messages, l));
                nb.setContentIntent(pIntent);
                nb.setNumber(l);
            }
        }
        // add pending intent
        i.setFlags(i.getFlags() | Intent.FLAG_ACTIVITY_NEW_TASK);

        if (enableNotifications && showNotification) {
            int[] ledFlash = PreferencesActivity.getLEDflash(context);
            nb.setLights(PreferencesActivity.getLEDcolor(context), ledFlash[0], ledFlash[1]);
            final SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(context);
            if (text != null) {
                final boolean vibrate = p.getBoolean(PreferencesActivity.PREFS_VIBRATE, false);
                final String s = p.getString(PreferencesActivity.PREFS_SOUND, null);
                Uri sound;
                if (s == null || s.length() <= 0) {
                    sound = null;
                } else {
                    sound = Uri.parse(s);
                }
                if (vibrate) {
                    final long[] pattern = PreferencesActivity.getVibratorPattern(context);
                    if (pattern.length == 1 && pattern[0] == 0) {
                        nb.setDefaults(Notification.DEFAULT_VIBRATE);
                    } else {
                        nb.setVibrate(pattern);
                    }
                }
                nb.setSound(sound);
            }
        }
        Log.d(TAG, "uri: ", uri);
        mNotificationMgr.cancel(NOTIFICATION_ID_NEW);
        if (enableNotifications && showNotification) {
            try {
                mNotificationMgr.notify(NOTIFICATION_ID_NEW, nb.getNotification());
            } catch (IllegalArgumentException e) {
                Log.e(TAG, "illegal notification: ", nb, e);
            }
        }
    }
    Log.d(TAG, "return ", l, " (2)");
    //noinspection ConstantConditions
    AppWidgetManager.getInstance(context).updateAppWidget(new ComponentName(context, WidgetProvider.class),
            WidgetProvider.getRemoteViews(context, l, pIntent));
    return l;
}

From source file:com.android.soma.Launcher.java

@Override
protected void onNewIntent(Intent intent) {
    long startTime = 0;
    if (DEBUG_RESUME_TIME) {
        startTime = System.currentTimeMillis();
    }//from  w  w w  .java  2s.  c  om
    super.onNewIntent(intent);

    // Close the menu
    if (Intent.ACTION_MAIN.equals(intent.getAction())) {
        // also will cancel mWaitingForResult.
        closeSystemDialogs();

        final boolean alreadyOnHome = mHasFocus && ((intent.getFlags()
                & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);

        if (mWorkspace == null) {
            // Can be cases where mWorkspace is null, this prevents a NPE
            return;
        }
        Folder openFolder = mWorkspace.getOpenFolder();
        // In all these cases, only animate if we're already on home
        mWorkspace.exitWidgetResizeMode();
        if (alreadyOnHome && mState == State.WORKSPACE && !mWorkspace.isTouchActive() && openFolder == null) {
            mWorkspace.moveToDefaultScreen(true);
        }

        closeFolder();
        exitSpringLoadedDragMode();

        // If we are already on home, then just animate back to the workspace,
        // otherwise, just wait until onResume to set the state back to Workspace
        if (alreadyOnHome) {
            showWorkspace(true);
        } else {
            mOnResumeState = State.WORKSPACE;
        }

        final View v = getWindow().peekDecorView();
        if (v != null && v.getWindowToken() != null) {
            InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
        }

        // Reset the apps customize page
        if (mAppsCustomizeTabHost != null) {
            mAppsCustomizeTabHost.reset();
        }
    }

    if (DEBUG_RESUME_TIME) {
        Log.d(TAG, "Time spent in onNewIntent: " + (System.currentTimeMillis() - startTime));
    }
}

From source file:com.filemanager.free.activities.MainActivity.java

protected void onActivityResult(int requestCode, int responseCode, Intent intent) {
    if (requestCode == RC_SIGN_IN && !mGoogleApiKey && mGoogleApiClient != null) {
        new Thread(new Runnable() {
            @Override/*from w  w w.j  ava2  s. com*/
            public void run() {
                mIntentInProgress = false;
                mGoogleApiKey = true;
                // !mGoogleApiClient.isConnecting
                if (mGoogleApiClient.isConnecting()) {
                    mGoogleApiClient.connect();
                } else
                    mGoogleApiClient.disconnect();

            }
        }).run();
    } else if (requestCode == image_selector_request_code) {
        if (Sp != null && intent != null && intent.getData() != null) {
            if (Build.VERSION.SDK_INT >= 19) {
                getContentResolver().takePersistableUriPermission(intent.getData(),
                        Intent.FLAG_GRANT_READ_URI_PERMISSION);
            } else {
                con.getApplicationContext().grantUriPermission(BuildConfig.APPLICATION_ID, intent.getData(),
                        Intent.FLAG_GRANT_READ_URI_PERMISSION);
            }

            Sp.edit().putString("drawer_header_path", intent.getData().toString()).commit();
            setDrawerHeaderBackground();
        }
    } else if (requestCode == 3) {
        String p = Sp.getString("URI", null);
        Uri oldUri = null;
        if (p != null)
            oldUri = Uri.parse(p);
        Uri treeUri = null;
        if (responseCode == Activity.RESULT_OK) {
            // Get Uri from Storage Access Framework.
            treeUri = intent.getData();
            // Persist URI - this is required for verification of writability.
            if (treeUri != null) {
                Sp.edit().putString("URI", treeUri.toString()).commit();
            }
        }
        // If not confirmed SAF, or if still not writable, then revert settings.
        if (responseCode != Activity.RESULT_OK) {
            /* DialogUtil.displayError(getActivity(), R.string.message_dialog_cannot_write_to_folder_saf, false,
                currentFolder);||!FileUtil.isWritableNormalOrSaf(currentFolder)
            */
            if (treeUri != null) {
                Sp.edit().putString("URI", oldUri.toString()).commit();
            }
            return;
        }

        // After confirmation, update stored value of folder.
        // Persist access permissions.
        int takeFlags = intent.getFlags();
        takeFlags &= (Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            if (treeUri != null) {
                getContentResolver().takePersistableUriPermission(treeUri, takeFlags);
            }
        } else {
            if (treeUri != null) {
                con.getApplicationContext().grantUriPermission(BuildConfig.APPLICATION_ID, treeUri, takeFlags);
            }
        }
        switch (operation) {
        case DataUtils.DELETE://deletion
            new DeleteTask(null, mainActivity).execute((oparrayList));
            break;
        case DataUtils.COPY://copying
            Intent intent1 = new Intent(con, CopyService.class);
            intent1.putExtra("FILE_PATHS", (oparrayList));
            intent1.putExtra("COPY_DIRECTORY", oppathe);
            startService(intent1);
            break;
        case DataUtils.MOVE://moving
            new MoveFiles((oparrayList), ((Main) getFragment().getTab()),
                    ((Main) getFragment().getTab()).getActivity(), 0)
                            .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, path);
            break;
        case DataUtils.NEW_FOLDER://mkdir
            Main ma1 = ((Main) getFragment().getTab());
            mainActivityHelper.mkDir(RootHelper.generateBaseFile(new File(oppathe), true), ma1);
            break;
        case DataUtils.RENAME:
            mainActivityHelper.rename(HFile.LOCAL_MODE, (oppathe), (oppathe1), mainActivity, rootmode);
            Main ma2 = ((Main) getFragment().getTab());
            ma2.updateList();
            break;
        case DataUtils.NEW_FILE:
            Main ma3 = ((Main) getFragment().getTab());
            mainActivityHelper.mkFile(new HFile(HFile.LOCAL_MODE, oppathe), ma3);

            break;
        case DataUtils.EXTRACT:
            mainActivityHelper.extractFile(new File(oppathe));
            break;
        case DataUtils.COMPRESS:
            mainActivityHelper.compressFiles(new File(oppathe), oparrayList);
        }
        operation = -1;
    }
}

From source file:xyz.klinker.blur.launcher3.Launcher.java

@Override
protected void onNewIntent(Intent intent) {
    long startTime = 0;
    if (DEBUG_RESUME_TIME) {
        startTime = System.currentTimeMillis();
    }//w  w w  . j av a  2 s.c o  m
    super.onNewIntent(intent);

    // Close the menu
    if (Intent.ACTION_MAIN.equals(intent.getAction())) {
        final boolean alreadyOnHome = mHasFocus && ((intent.getFlags()
                & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);

        if (mLauncherDrawer.isDrawerOpen(Gravity.LEFT)) {
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    mLauncherDrawer.closeDrawer(Gravity.LEFT);
                }
            }, 300);

            return;
        } else if (mLauncherDrawer.isDrawerOpen(Gravity.RIGHT)) {
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    mLauncherDrawer.closeDrawer(Gravity.RIGHT);
                }
            }, 300);

            return;
        } else if (!isAllAppsVisible() && alreadyOnHome && mWorkspace.getCurrentPage() == 0
                && !mWorkspace.isInOverviewMode()) {
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    GestureUtils.runGesture(Launcher.this, Launcher.this, AppSettings.HOME_BUTTON);
                }
            }, 300);

            return;
        }

        // also will cancel mWaitingForResult.
        closeSystemDialogs();

        if (mWorkspace == null) {
            // Can be cases where mWorkspace is null, this prevents a NPE
            return;
        }
        // In all these cases, only animate if we're already on home
        mWorkspace.exitWidgetResizeMode();

        closeFolder(alreadyOnHome);
        exitSpringLoadedDragMode();

        // If we are already on home, then just animate back to the workspace,
        // otherwise, just wait until onResume to set the state back to Workspace
        if (alreadyOnHome) {
            showWorkspace(true);
        } else {
            mOnResumeState = State.WORKSPACE;
        }

        final View v = getWindow().peekDecorView();
        if (v != null && v.getWindowToken() != null) {
            InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
        }

        // Reset the apps view
        if (!alreadyOnHome && mAppsView != null) {
            mAppsView.scrollToTop();
        }

        // Reset the widgets view
        if (!alreadyOnHome && mWidgetsView != null) {
            mWidgetsView.scrollToTop();
        }

        if (mLauncherCallbacks != null) {
            mLauncherCallbacks.onHomeIntent();
        }
    }

    if (mLauncherCallbacks != null) {
        mLauncherCallbacks.onNewIntent(intent);
    }

    if (DEBUG_RESUME_TIME) {
        Log.d(TAG, "Time spent in onNewIntent: " + (System.currentTimeMillis() - startTime));
    }
}

From source file:com.cognizant.trumobi.PersonaLauncher.java

@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);

    // Close the menu
    if (Intent.ACTION_MAIN.equals(intent.getAction())) {
        closeSystemDialogs();/*  ww w  .  ja v  a2 s  . co m*/

        // Set this flag so that onResume knows to close the search dialog
        // if it's open,
        // because this was a new intent (thus a press of 'home' or some
        // such) rather than
        // for example onResume being called when the user pressed the
        // 'back' button.
        mIsNewIntent = true;

        if ((intent.getFlags()
                & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) {
            if (!isAllAppsVisible() || mHomeBinding == BIND_APPS)
                fireHomeBinding(mHomeBinding, 1);
            if (mHomeBinding != BIND_APPS) {
                closeDrawer(true);

            }
            final View v = getWindow().peekDecorView();
            if (v != null && v.getWindowToken() != null) {
                InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
            }
        } else {
            closeDrawer(false);
        }
    }
}

From source file:g7.bluesky.launcher3.Launcher.java

@Override
protected void onNewIntent(Intent intent) {
    long startTime = 0;
    if (DEBUG_RESUME_TIME) {
        startTime = System.currentTimeMillis();
    }// ww  w  . jav a 2 s .  c  o m
    super.onNewIntent(intent);

    // Close the menu
    if (Intent.ACTION_MAIN.equals(intent.getAction())) {
        // also will cancel mWaitingForResult.
        closeSystemDialogs();

        final boolean alreadyOnHome = mHasFocus && ((intent.getFlags()
                & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);

        if (mWorkspace == null) {
            // Can be cases where mWorkspace is null, this prevents a NPE
            return;
        }
        Folder openFolder = mWorkspace.getOpenFolder();
        // In all these cases, only animate if we're already on home
        mWorkspace.exitWidgetResizeMode();

        boolean moveToDefaultScreen = mLauncherCallbacks != null
                ? mLauncherCallbacks.shouldMoveToDefaultScreenOnHomeIntent()
                : true;
        if (alreadyOnHome && mState == State.WORKSPACE && !mWorkspace.isTouchActive() && openFolder == null
                && moveToDefaultScreen) {
            mWorkspace.moveToDefaultScreen(true);
        }

        closeFolder();
        exitSpringLoadedDragMode();

        // If we are already on home, then just animate back to the workspace,
        // otherwise, just wait until onResume to set the state back to Workspace
        if (alreadyOnHome) {
            showWorkspace(true);
        } else {
            mOnResumeState = State.WORKSPACE;
        }

        final View v = getWindow().peekDecorView();
        if (v != null && v.getWindowToken() != null) {
            InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
        }

        // Reset the apps customize page
        if (!alreadyOnHome && mAppsCustomizeTabHost != null) {
            mAppsCustomizeTabHost.reset();
        }

        if (mLauncherCallbacks != null) {
            mLauncherCallbacks.onHomeIntent();
        }
    }

    if (DEBUG_RESUME_TIME) {
        Log.d(TAG, "Time spent in onNewIntent: " + (System.currentTimeMillis() - startTime));
    }

    if (mLauncherCallbacks != null) {
        mLauncherCallbacks.onNewIntent(intent);
    }
}

From source file:com.zoffcc.applications.zanavi.Navit.java

protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);

    try {//from   w  ww. j  av a  2s .  c  om
        System.out.println("XXIIXX(2):111");
        String mid_str = intent.getExtras().getString("com.zoffcc.applications.zanavi.mid");

        System.out.println("XXIIXX(2):111a:mid_str=" + mid_str);

        if (mid_str != null) {
            if (mid_str.equals("201:UPDATE-APP")) {
                // a new ZANavi version is available, show something to the user here -------------------
                // a new ZANavi version is available, show something to the user here -------------------
                // a new ZANavi version is available, show something to the user here -------------------
                // a new ZANavi version is available, show something to the user here -------------------
                // a new ZANavi version is available, show something to the user here -------------------
                // a new ZANavi version is available, show something to the user here -------------------
            } else if (mid_str.startsWith("202:UPDATE-MAP:")) {
                // System.out.println("need to update1:" + mid_str);
                // System.out.println("need to update2:" + mid_str.substring(15));

                auto_start_update_map(mid_str.substring(15));
            }
        }

        System.out.println("XXIIXX(2):111b:mid_str=" + mid_str);
    } catch (Exception e) {
        e.printStackTrace();
        System.out.println("XXIIXX(2):111:EEEE");
    }

    // ---- Intent dump ----
    // ---- Intent dump ----
    // ---- Intent dump ----
    // ---- Intent dump ----
    try {
        System.out.println("XXIIXX(2):" + intent);
        Bundle bundle77 = intent.getExtras();
        System.out.println("XXIIXX(2):" + intent_flags_to_string(intent.getFlags()));
        if (bundle77 == null) {
            System.out.println("XXIIXX(2):" + "null");
        } else {
            for (String key : bundle77.keySet()) {
                Object value = bundle77.get(key);
                System.out.println("XXIIXX(2):"
                        + String.format("%s %s (%s)", key, value.toString(), value.getClass().getName()));
            }
        }
    } catch (Exception ee22) {
        String exst = Log.getStackTraceString(ee22);
        System.out.println("XXIIXX(2):ERR:" + exst);
    }
    // ---- Intent dump ----
    // ---- Intent dump ----
    // ---- Intent dump ----
    // ---- Intent dump ----

    Log.e("Navit", "3:**1**A " + intent.getAction());
    Log.e("Navit", "3:**1**D " + intent.getDataString());
    Log.e("Navit", "3:**1**S " + intent.toString());
    try {
        Log.e("Navit", "3:**1**S " + intent.getExtras().describeContents());
    } catch (Exception ee3) {
    }

    // if (Navit.startup_intent == null)
    {
        try {
            // make a copy of the given intent object
            // Navit.startup_intent = intent.cloneFilter();
            Navit.startup_intent = intent;

            Log.e("Navit", "3a:**1**001");
            Bundle extras2 = intent.getExtras();
            Log.e("Navit", "3a:**1**002");
            try {
                Navit.startup_intent.putExtras(extras2);
                Log.e("Navit", "3a:**1**003");
            } catch (Exception e4) {
                if (startup_intent.getDataString() != null) {
                    // we have a "geo:" thingy intent, use it
                    // or "gpx file"
                    Log.e("Navit", "3c:**1**A " + startup_intent.getAction());
                    Log.e("Navit", "3c:**1**D " + startup_intent.getDataString());
                    Log.e("Navit", "3c:**1**S " + startup_intent.toString());
                } else {
                    Log.e("Navit", "3X:**1**X ");
                    Navit.startup_intent = null;
                }

                // hack! remeber timstamp, and only allow 4 secs. later in onResume to set target!
                Navit.startup_intent_timestamp = System.currentTimeMillis();

                return;
            }

            // Intent { act=android.intent.action.VIEW
            // cat=[android.intent.category.DEFAULT]
            // dat=file:///mnt/sdcard/zanavi_pos_recording_347834278.gpx
            // cmp=com.zoffcc.applications.zanavi/.Navit }

            // hack! remeber timstamp, and only allow 4 secs. later in onResume to set target!
            Navit.startup_intent_timestamp = System.currentTimeMillis();
            Log.e("Navit", "3a:**1**A " + startup_intent.getAction());
            Log.e("Navit", "3a:**1**D " + startup_intent.getDataString());
            Log.e("Navit", "3a:**1**S " + startup_intent.toString());
            if (extras2 != null) {
                long l = extras2.getLong("com.zoffcc.applications.zanavi.ZANAVI_INTENT_type");
                // System.out.println("DH:a007 l=" + l);
                if (l != 0L) {
                    if (l == Navit.NAVIT_START_INTENT_DRIVE_HOME) {
                        // Log.e("Navit", "2:**1** started via drive home");
                        // we have been called from "drive home" widget

                        // drive home

                        // check if we have a home location
                        int home_id = find_home_point();

                        if (home_id != -1) {
                            Message msg7 = progress_handler.obtainMessage();
                            Bundle b7 = new Bundle();
                            msg7.what = 2; // long Toast message
                            b7.putString("text", Navit.get_text("driving to Home Location")); //TRANS
                            msg7.setData(b7);
                            progress_handler.sendMessage(msg7);

                            // clear any previous destinations
                            Message msg2 = new Message();
                            Bundle b2 = new Bundle();
                            b2.putInt("Callback", 7);
                            msg2.setData(b2);
                            NavitGraphics.callback_handler.sendMessage(msg2);

                            // set position to middle of screen -----------------------
                            // set position to middle of screen -----------------------
                            // set position to middle of screen -----------------------
                            //               Message msg67 = new Message();
                            //               Bundle b67 = new Bundle();
                            //               b67.putInt("Callback", 51);
                            //               b67.putInt("x", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getWidth() / 2));
                            //               b67.putInt("y", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getHeight() / 2));
                            //               msg67.setData(b67);
                            //               N_NavitGraphics.callback_handler.sendMessage(msg67);
                            // set position to middle of screen -----------------------
                            // set position to middle of screen -----------------------
                            // set position to middle of screen -----------------------

                            try {
                                Thread.sleep(60);
                            } catch (Exception e) {
                            }

                            route_wrapper(map_points.get(home_id).point_name, 0, 0, false,
                                    map_points.get(home_id).lat, map_points.get(home_id).lon, true);

                            //                        Navit.destination_set();
                            //
                            //                        // set destination to home location
                            //                        String lat = String.valueOf(map_points.get(home_id).lat);
                            //                        String lon = String.valueOf(map_points.get(home_id).lon);
                            //                        String q = map_points.get(home_id).point_name;
                            //
                            //                        // System.out.println("lat=" + lat + " lon=" + lon + " name=" + q);
                            //
                            //                        Message msg55 = new Message();
                            //                        Bundle b55 = new Bundle();
                            //                        b55.putInt("Callback", 3);
                            //                        b55.putString("lat", lat);
                            //                        b55.putString("lon", lon);
                            //                        b55.putString("q", q);
                            //                        msg55.setData(b55);
                            //                        NavitGraphics.callback_handler.sendMessage(msg55);

                            final Thread zoom_to_route_001 = new Thread() {
                                int wait = 1;
                                int count = 0;
                                int max_count = 60;

                                @Override
                                public void run() {
                                    while (wait == 1) {
                                        try {
                                            if ((NavitGraphics.navit_route_status == 17)
                                                    || (NavitGraphics.navit_route_status == 33)) {
                                                zoom_to_route();
                                                wait = 0;
                                            } else {
                                                wait = 1;
                                            }

                                            count++;
                                            if (count > max_count) {
                                                wait = 0;
                                            } else {
                                                Thread.sleep(400);
                                            }
                                        } catch (Exception e) {
                                        }
                                    }
                                }
                            };
                            zoom_to_route_001.start();

                            //               try
                            //               {
                            //                  show_geo_on_screen(Float.parseFloat(lat), Float.parseFloat(lon));
                            //               }
                            //               catch (Exception e2)
                            //               {
                            //                  e2.printStackTrace();
                            //               }

                            try {
                                Navit.follow_button_on();
                            } catch (Exception e2) {
                                e2.printStackTrace();
                            }
                        } else {
                            // no home location set
                            Message msg = progress_handler.obtainMessage();
                            Bundle b = new Bundle();
                            msg.what = 2; // long Toast message
                            b.putString("text", Navit.get_text("No Home Location set")); //TRANS
                            msg.setData(b);
                            progress_handler.sendMessage(msg);
                        }

                    }
                } else {
                    if (startup_intent.getDataString() != null) {
                        // we have a "geo:" thingy intent, use it
                        // or "gpx file"
                    } else {
                        Navit.startup_intent = null;
                    }
                }
            } else {
                if (startup_intent.getDataString() != null) {
                    // we have a "geo:" thingy intent, use it
                } else {
                    Navit.startup_intent = null;
                }
            }
        } catch (Exception e99) {
            Navit.startup_intent = null;
        }

    }

}