Example usage for android.content Intent CATEGORY_DEFAULT

List of usage examples for android.content Intent CATEGORY_DEFAULT

Introduction

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

Prototype

String CATEGORY_DEFAULT

To view the source code for android.content Intent CATEGORY_DEFAULT.

Click Source Link

Document

Set if the activity should be an option for the default action (center press) to perform on a piece of data.

Usage

From source file:edu.mines.letschat.GcmIntentService.java

protected PendingIntent getDeleteIntent() {
    Intent resultBroadCastIntent = new Intent();
    resultBroadCastIntent.setAction("deletion");
    resultBroadCastIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
    resultBroadCastIntent.addCategory(Intent.CATEGORY_DEFAULT);
    sendBroadcast(resultBroadCastIntent);
    return PendingIntent.getBroadcast(getBaseContext(), 0, resultBroadCastIntent,
            PendingIntent.FLAG_CANCEL_CURRENT);
}

From source file:gov.wa.wsdot.android.wsdot.service.BorderWaitSyncService.java

@Override
protected void onHandleIntent(Intent intent) {
    ContentResolver resolver = getContentResolver();
    Cursor cursor = null;/*  ww  w . j  av  a 2  s .com*/
    long now = System.currentTimeMillis();
    boolean shouldUpdate = true;
    String responseString = "";

    /** 
     * Check the cache table for the last time data was downloaded. If we are within
     * the allowed time period, don't sync, otherwise get fresh data from the server.
     */
    try {
        cursor = resolver.query(Caches.CONTENT_URI, new String[] { Caches.CACHE_LAST_UPDATED },
                Caches.CACHE_TABLE_NAME + " LIKE ?", new String[] { "border_wait" }, null);

        if (cursor != null && cursor.moveToFirst()) {
            long lastUpdated = cursor.getLong(0);
            //long deltaMinutes = (now - lastUpdated) / DateUtils.MINUTE_IN_MILLIS;
            //Log.d(DEBUG_TAG, "Delta since last update is " + deltaMinutes + " min");
            shouldUpdate = (Math.abs(now - lastUpdated) > (15 * DateUtils.MINUTE_IN_MILLIS));
        }
    } finally {
        if (cursor != null) {
            cursor.close();
        }
    }

    // Ability to force a refresh of camera data.
    boolean forceUpdate = intent.getBooleanExtra("forceUpdate", false);

    if (shouldUpdate || forceUpdate) {
        List<Integer> starred = new ArrayList<Integer>();

        starred = getStarred();

        try {
            URL url = new URL(BORDER_WAIT_URL);
            URLConnection urlConn = url.openConnection();

            BufferedReader in = new BufferedReader(new InputStreamReader(urlConn.getInputStream()));
            String jsonFile = "";
            String line;

            while ((line = in.readLine()) != null)
                jsonFile += line;
            in.close();

            JSONObject obj = new JSONObject(jsonFile);
            JSONObject result = obj.getJSONObject("waittimes");
            JSONArray items = result.getJSONArray("items");
            List<ContentValues> times = new ArrayList<ContentValues>();

            int numItems = items.length();
            for (int j = 0; j < numItems; j++) {
                JSONObject item = items.getJSONObject(j);
                ContentValues timesValues = new ContentValues();
                timesValues.put(BorderWait.BORDER_WAIT_ID, item.getInt("id"));
                timesValues.put(BorderWait.BORDER_WAIT_TITLE, item.getString("name"));
                timesValues.put(BorderWait.BORDER_WAIT_UPDATED, item.getString("updated"));
                timesValues.put(BorderWait.BORDER_WAIT_LANE, item.getString("lane"));
                timesValues.put(BorderWait.BORDER_WAIT_ROUTE, item.getInt("route"));
                timesValues.put(BorderWait.BORDER_WAIT_DIRECTION, item.getString("direction"));
                timesValues.put(BorderWait.BORDER_WAIT_TIME, item.getInt("wait"));

                if (starred.contains(item.getInt("id"))) {
                    timesValues.put(BorderWait.BORDER_WAIT_IS_STARRED, 1);
                }

                times.add(timesValues);

            }

            // Purge existing border wait times covered by incoming data
            resolver.delete(BorderWait.CONTENT_URI, null, null);
            // Bulk insert all the new travel times
            resolver.bulkInsert(BorderWait.CONTENT_URI, times.toArray(new ContentValues[times.size()]));
            // Update the cache table with the time we did the update
            ContentValues values = new ContentValues();
            values.put(Caches.CACHE_LAST_UPDATED, System.currentTimeMillis());
            resolver.update(Caches.CONTENT_URI, values, Caches.CACHE_TABLE_NAME + "=?",
                    new String[] { "border_wait" });

            responseString = "OK";

        } catch (Exception e) {
            Log.e(DEBUG_TAG, "Error: " + e.getMessage());
            responseString = e.getMessage();
        }
    } else {
        responseString = "NOP";
    }

    Intent broadcastIntent = new Intent();
    broadcastIntent.setAction("gov.wa.wsdot.android.wsdot.intent.action.BORDER_WAIT_RESPONSE");
    broadcastIntent.addCategory(Intent.CATEGORY_DEFAULT);
    broadcastIntent.putExtra("responseString", responseString);
    sendBroadcast(broadcastIntent);

}

From source file:org.linkdroid.BroadcastReceiverService.java

private void enableIntentFilterAtCursor(Cursor c) throws MalformedMimeTypeException {
    final IntentFilter intentFilter = new IntentFilter();
    final String intentStr = c.getString(c.getColumnIndexOrThrow(ACTION));
    intentFilter.addAction(intentStr);/*www  .j a v  a2  s  .  c o  m*/
    final String categoryStr = c.getString(c.getColumnIndexOrThrow(CATEGORY));
    if (StringUtils.isBlank(categoryStr)) {
        intentFilter.addCategory(Intent.CATEGORY_DEFAULT);
    } else {
        intentFilter.addCategory(categoryStr);
    }
    final String dataAuthHostStr = c.getString(c.getColumnIndexOrThrow(DATA_AUTHORITY_HOST));
    final String dataAuthPortStr = c.getString(c.getColumnIndexOrThrow(DATA_AUTHORITY_PORT));
    if (!StringUtils.isBlank(dataAuthHostStr)) {
        intentFilter.addDataAuthority(dataAuthHostStr, dataAuthPortStr);
    }
    final String dataSchemeStr = c.getString(c.getColumnIndexOrThrow(DATA_SCHEME));
    if (!StringUtils.isBlank(dataSchemeStr)) {
        intentFilter.addDataScheme(dataSchemeStr);
    }
    final String dataTypeStr = c.getString(c.getColumnIndexOrThrow(DATA_TYPE));
    if (!StringUtils.isBlank(dataTypeStr)) {
        intentFilter.addDataType(dataTypeStr);
    }
    registerReceiver(receiver, intentFilter);
    Log.d(TAG, "registered intent filter " + intentStr);
}

From source file:io.indy.drone.activity.StrikeListActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_strike_list);

    ifd("onCreate");

    mDatabase = new SQLDatabase(this);
    //mStrikeMapHelper = new StrikeMapHelper(this);

    if (findViewById(R.id.strike_detail_container) != null) {
        // The detail container view will be present only in the
        // large-screen layouts (res/values-large and
        // res/values-sw600dp). If this view is present, then the
        // activity should be in two-pane mode.
        mTwoPane = true;//from   w w w  .j a  v a  2s.com

        // In two-pane mode, list items should be given the
        // 'activated' state when touched.
        ((StrikeListFragment) getSupportFragmentManager().findFragmentById(R.id.strike_list))
                .setActivateOnItemClick(true);
    }

    if (savedInstanceState != null) {
        mStrikeId = savedInstanceState.getString(SQLDatabase.KEY_ID);
        mRegion = savedInstanceState.getString(SQLDatabase.REGION);
    } else {
        mRegion = SQLDatabase.regionFromIndex(0);
        mStrikeId = "";//mDatabase.getRecentStrikeIdInRegion(mRegion);
    }

    mStrikeLocations = mDatabase.getStrikeLocationsInRegion(mRegion);
    mStrikeMapHelper = new StrikeMapHelper(this);
    if (!mStrikeId.isEmpty()) {
        showStrikeOnMap(mStrikeId);
    }

    IntentFilter filter = new IntentFilter(ResponseReceiver.ACTION_RESP);
    filter.addCategory(Intent.CATEGORY_DEFAULT);
    mResponseReceiver = new ResponseReceiver();
    registerReceiver(mResponseReceiver, filter);

    setupNavigationDrawer();
    setupAlarm();
}

From source file:gov.wa.wsdot.android.wsdot.service.CamerasSyncService.java

@Override
protected void onHandleIntent(Intent intent) {
    ContentResolver resolver = getContentResolver();
    Cursor cursor = null;/* w w w.j a v a 2 s  .com*/
    long now = System.currentTimeMillis();
    boolean shouldUpdate = true;
    String responseString = "";

    /** 
     * Check the cache table for the last time data was downloaded. If we are within
     * the allowed time period, don't sync, otherwise get fresh data from the server.
     */
    try {
        cursor = resolver.query(Caches.CONTENT_URI, projection, Caches.CACHE_TABLE_NAME + " LIKE ?",
                new String[] { "cameras" }, null);

        if (cursor != null && cursor.moveToFirst()) {
            long lastUpdated = cursor.getLong(0);
            //long deltaDays = (now - lastUpdated) / DateUtils.DAY_IN_MILLIS;
            //Log.d(DEBUG_TAG, "Delta since last update is " + deltaDays + " day(s)");
            shouldUpdate = (Math.abs(now - lastUpdated) > (7 * DateUtils.DAY_IN_MILLIS));
        }
    } finally {
        if (cursor != null) {
            cursor.close();
        }
    }

    // Ability to force a refresh of camera data.
    boolean forceUpdate = intent.getBooleanExtra("forceUpdate", false);

    if (shouldUpdate || forceUpdate) {
        List<Integer> starred = new ArrayList<Integer>();

        starred = getStarred();

        try {
            URL url = new URL(CAMERAS_URL);
            URLConnection urlConn = url.openConnection();

            BufferedInputStream bis = new BufferedInputStream(urlConn.getInputStream());
            GZIPInputStream gzin = new GZIPInputStream(bis);
            InputStreamReader is = new InputStreamReader(gzin);
            BufferedReader in = new BufferedReader(is);

            String jsonFile = "";
            String line;
            while ((line = in.readLine()) != null)
                jsonFile += line;
            in.close();

            JSONObject obj = new JSONObject(jsonFile);
            JSONObject result = obj.getJSONObject("cameras");
            JSONArray items = result.getJSONArray("items");
            List<ContentValues> cams = new ArrayList<ContentValues>();

            int numItems = items.length();
            for (int j = 0; j < numItems; j++) {
                JSONObject item = items.getJSONObject(j);
                ContentValues cameraData = new ContentValues();

                cameraData.put(Cameras.CAMERA_ID, item.getString("id"));
                cameraData.put(Cameras.CAMERA_TITLE, item.getString("title"));
                cameraData.put(Cameras.CAMERA_URL, item.getString("url"));
                cameraData.put(Cameras.CAMERA_LATITUDE, item.getString("lat"));
                cameraData.put(Cameras.CAMERA_LONGITUDE, item.getString("lon"));
                cameraData.put(Cameras.CAMERA_HAS_VIDEO, item.getString("video"));
                cameraData.put(Cameras.CAMERA_ROAD_NAME, item.getString("roadName"));

                if (starred.contains(Integer.parseInt(item.getString("id")))) {
                    cameraData.put(Cameras.CAMERA_IS_STARRED, 1);
                }

                cams.add(cameraData);
            }

            // Purge existing cameras covered by incoming data
            resolver.delete(Cameras.CONTENT_URI, null, null);
            // Bulk insert all the new cameras
            resolver.bulkInsert(Cameras.CONTENT_URI, cams.toArray(new ContentValues[cams.size()]));
            // Update the cache table with the time we did the update
            ContentValues values = new ContentValues();
            values.put(Caches.CACHE_LAST_UPDATED, System.currentTimeMillis());
            resolver.update(Caches.CONTENT_URI, values, Caches.CACHE_TABLE_NAME + " LIKE ?",
                    new String[] { "cameras" });

            responseString = "OK";
        } catch (Exception e) {
            Log.e(DEBUG_TAG, "Error: " + e.getMessage());
            responseString = e.getMessage();
        }
    } else {
        responseString = "NOP";
    }

    Intent broadcastIntent = new Intent();
    broadcastIntent.setAction("gov.wa.wsdot.android.wsdot.intent.action.CAMERAS_RESPONSE");
    broadcastIntent.addCategory(Intent.CATEGORY_DEFAULT);
    broadcastIntent.putExtra("responseString", responseString);
    sendBroadcast(broadcastIntent);
}

From source file:gov.wa.wsdot.android.wsdot.service.TravelTimesSyncService.java

@Override
protected void onHandleIntent(Intent intent) {
    ContentResolver resolver = getContentResolver();
    Cursor cursor = null;/*from  w  w  w  .j  a v  a 2 s .  co m*/
    long now = System.currentTimeMillis();
    boolean shouldUpdate = true;
    String responseString = "";

    /** 
     * Check the cache table for the last time data was downloaded. If we are within
     * the allowed time period, don't sync, otherwise get fresh data from the server.
     */
    try {
        cursor = resolver.query(Caches.CONTENT_URI, new String[] { Caches.CACHE_LAST_UPDATED },
                Caches.CACHE_TABLE_NAME + " LIKE ?", new String[] { "travel_times" }, null);

        if (cursor != null && cursor.moveToFirst()) {
            long lastUpdated = cursor.getLong(0);
            //long deltaMinutes = (now - lastUpdated) / DateUtils.MINUTE_IN_MILLIS;
            //Log.d(DEBUG_TAG, "Delta since last update is " + deltaMinutes + " min");
            shouldUpdate = (Math.abs(now - lastUpdated) > (5 * DateUtils.MINUTE_IN_MILLIS));
        }
    } finally {
        if (cursor != null) {
            cursor.close();
        }
    }

    // Ability to force a refresh of camera data.
    boolean forceUpdate = intent.getBooleanExtra("forceUpdate", false);

    if (shouldUpdate || forceUpdate) {
        List<Integer> starred = new ArrayList<Integer>();

        starred = getStarred();

        try {
            URL url = new URL(TRAVEL_TIMES_URL);
            URLConnection urlConn = url.openConnection();

            BufferedInputStream bis = new BufferedInputStream(urlConn.getInputStream());
            GZIPInputStream gzin = new GZIPInputStream(bis);
            InputStreamReader is = new InputStreamReader(gzin);
            BufferedReader in = new BufferedReader(is);

            String jsonFile = "";
            String line;

            while ((line = in.readLine()) != null)
                jsonFile += line;
            in.close();

            JSONObject obj = new JSONObject(jsonFile);
            JSONObject result = obj.getJSONObject("traveltimes");
            JSONArray items = result.getJSONArray("items");
            List<ContentValues> times = new ArrayList<ContentValues>();

            int numItems = items.length();
            for (int j = 0; j < numItems; j++) {
                JSONObject item = items.getJSONObject(j);
                ContentValues timesValues = new ContentValues();
                timesValues.put(TravelTimes.TRAVEL_TIMES_TITLE, item.getString("title"));
                timesValues.put(TravelTimes.TRAVEL_TIMES_CURRENT, item.getInt("current"));
                timesValues.put(TravelTimes.TRAVEL_TIMES_AVERAGE, item.getInt("average"));
                timesValues.put(TravelTimes.TRAVEL_TIMES_DISTANCE, item.getString("distance") + " miles");
                timesValues.put(TravelTimes.TRAVEL_TIMES_ID, Integer.parseInt(item.getString("routeid")));
                timesValues.put(TravelTimes.TRAVEL_TIMES_UPDATED, item.getString("updated"));

                if (starred.contains(Integer.parseInt(item.getString("routeid")))) {
                    timesValues.put(TravelTimes.TRAVEL_TIMES_IS_STARRED, 1);
                }

                times.add(timesValues);
            }

            // Purge existing travel times covered by incoming data
            resolver.delete(TravelTimes.CONTENT_URI, null, null);
            // Bulk insert all the new travel times
            resolver.bulkInsert(TravelTimes.CONTENT_URI, times.toArray(new ContentValues[times.size()]));
            // Update the cache table with the time we did the update
            ContentValues values = new ContentValues();
            values.put(Caches.CACHE_LAST_UPDATED, System.currentTimeMillis());
            resolver.update(Caches.CONTENT_URI, values, Caches.CACHE_TABLE_NAME + "=?",
                    new String[] { "travel_times" });

            responseString = "OK";
        } catch (Exception e) {
            Log.e(DEBUG_TAG, "Error: " + e.getMessage());
            responseString = e.getMessage();
        }

    } else {
        responseString = "NOP";
    }

    Intent broadcastIntent = new Intent();
    broadcastIntent.setAction("gov.wa.wsdot.android.wsdot.intent.action.TRAVEL_TIMES_RESPONSE");
    broadcastIntent.addCategory(Intent.CATEGORY_DEFAULT);
    broadcastIntent.putExtra("responseString", responseString);
    sendBroadcast(broadcastIntent);
}

From source file:online.privacy.SetupActivity.java

@Override
protected void onStart() {
    super.onStart();

    // Register the IntentService Listeners to get the response of the user check and location list.
    IntentFilter verifyFilter = new IntentFilter(VerifyUserAccountReceiver.API_RESPONSE);
    verifyFilter.addCategory(Intent.CATEGORY_DEFAULT);
    verifyReceiver = new VerifyUserAccountReceiver();
    registerReceiver(verifyReceiver, verifyFilter);

    // Register the NetworkReceiver to listen for changes to connectivity.
    IntentFilter networkChangeFilter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
    networkReceiver = new NetworkReceiver();
    this.registerReceiver(networkReceiver, networkChangeFilter);

    // Populate the Location list.
    VPNLocations vpnLocations = new VPNLocations(this);
    ArrayList<VPNLocation> locationList = vpnLocations.getArrayList();
    final VPNLocationAdapter locationAdapter = new VPNLocationAdapter(this, R.layout.spinner_layout_full,
            locationList);/*from   w  ww . ja v  a 2 s .c o m*/
    PrivacyOnlineUtility utility = new PrivacyOnlineUtility();
    utility.updateSpinnerValues(activitySetup, R.id.input_spinner_default_vpn_location, locationAdapter, false,
            new AdapterView.OnItemSelectedListener() {
                @Override
                public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
                    VPNLocation location = locationAdapter.getItem(position);
                    defaultVPNLocationUpdate = location.getHostname();
                }

                @Override
                public void onNothingSelected(AdapterView<?> adapter) {
                }
            });
}

From source file:io.rapidpro.androidchannel.HomeActivity.java

public void onResume() {
    super.onResume();

    // listen for dashboard update events
    m_receiver = new DashboardReceiver();
    IntentFilter filter = new IntentFilter();
    filter.addAction(Intents.UPDATE_STATUS);
    filter.addAction(Intents.UPDATE_COUNTS);
    filter.addAction(Intents.UPDATE_RELAYER_STATE);
    filter.addCategory(Intent.CATEGORY_DEFAULT);
    registerReceiver(m_receiver, filter);

    RapidPro.broadcastUpdatedCounts(this);

    updateClaimCode(this);

    // if we aren't claimed, force a sync
    if (!RapidPro.get().isClaimed()) {
        RapidPro.get().sync(true);/*from w ww.  ja  v a2 s  . c o m*/
    }
}

From source file:gov.wa.wsdot.android.wsdot.service.FerriesTerminalSailingSpaceSyncService.java

@Override
protected void onHandleIntent(Intent intent) {
    ContentResolver resolver = getContentResolver();
    Cursor cursor = null;/*from   w w w .ja  va 2  s.  c  o  m*/
    long now = System.currentTimeMillis();
    boolean shouldUpdate = true;
    String responseString = "";
    DateFormat dateFormat = new SimpleDateFormat("MMMM d, yyyy h:mm a");

    /** 
     * Check the cache table for the last time data was downloaded. If we are within
     * the allowed time period, don't sync, otherwise get fresh data from the server.
     */
    try {
        cursor = resolver.query(Caches.CONTENT_URI, new String[] { Caches.CACHE_LAST_UPDATED },
                Caches.CACHE_TABLE_NAME + " LIKE ?", new String[] { "ferries_terminal_sailing_space" }, null);

        if (cursor != null && cursor.moveToFirst()) {
            long lastUpdated = cursor.getLong(0);
            shouldUpdate = (Math.abs(now - lastUpdated) > (15 * DateUtils.SECOND_IN_MILLIS));
        }
    } finally {
        if (cursor != null) {
            cursor.close();
        }
    }

    // Ability to force a refresh of camera data.
    boolean forceUpdate = intent.getBooleanExtra("forceUpdate", false);

    if (shouldUpdate || forceUpdate) {
        List<Integer> starred = new ArrayList<Integer>();

        starred = getStarred();

        try {
            URL url = new URL(TERMINAL_SAILING_SPACE_URL);
            URLConnection urlConn = url.openConnection();

            BufferedReader in = new BufferedReader(new InputStreamReader(urlConn.getInputStream()));
            String jsonFile = "";
            String line;

            while ((line = in.readLine()) != null)
                jsonFile += line;
            in.close();

            JSONArray array = new JSONArray(jsonFile);
            List<ContentValues> terminal = new ArrayList<ContentValues>();

            int numItems = array.length();
            for (int j = 0; j < numItems; j++) {
                JSONObject item = array.getJSONObject(j);
                ContentValues sailingSpaceValues = new ContentValues();
                sailingSpaceValues.put(FerriesTerminalSailingSpace.TERMINAL_ID, item.getInt("TerminalID"));
                sailingSpaceValues.put(FerriesTerminalSailingSpace.TERMINAL_NAME,
                        item.getString("TerminalName"));
                sailingSpaceValues.put(FerriesTerminalSailingSpace.TERMINAL_ABBREV,
                        item.getString("TerminalAbbrev"));
                sailingSpaceValues.put(FerriesTerminalSailingSpace.TERMINAL_DEPARTING_SPACES,
                        item.getString("DepartingSpaces"));
                sailingSpaceValues.put(FerriesTerminalSailingSpace.TERMINAL_LAST_UPDATED,
                        dateFormat.format(new Date(System.currentTimeMillis())));

                if (starred.contains(item.getInt("TerminalID"))) {
                    sailingSpaceValues.put(FerriesTerminalSailingSpace.TERMINAL_IS_STARRED, 1);
                }

                terminal.add(sailingSpaceValues);
            }

            // Purge existing terminal sailing space items covered by incoming data
            resolver.delete(FerriesTerminalSailingSpace.CONTENT_URI, null, null);
            // Bulk insert all the new terminal sailing space items
            resolver.bulkInsert(FerriesTerminalSailingSpace.CONTENT_URI,
                    terminal.toArray(new ContentValues[terminal.size()]));
            // Update the cache table with the time we did the update
            ContentValues values = new ContentValues();
            values.put(Caches.CACHE_LAST_UPDATED, System.currentTimeMillis());
            resolver.update(Caches.CONTENT_URI, values, Caches.CACHE_TABLE_NAME + "=?",
                    new String[] { "ferries_terminal_sailing_space" });

            responseString = "OK";

        } catch (Exception e) {
            Log.e(TAG, "Error: " + e.getMessage());
            responseString = e.getMessage();
        }
    } else {
        responseString = "NOP";
    }

    Intent broadcastIntent = new Intent();
    broadcastIntent
            .setAction("gov.wa.wsdot.android.wsdot.intent.action.FERRIES_TERMINAL_SAILING_SPACE_RESPONSE");
    broadcastIntent.addCategory(Intent.CATEGORY_DEFAULT);
    broadcastIntent.putExtra("responseString", responseString);
    sendBroadcast(broadcastIntent);
}

From source file:com.ivanmagda.inventory.ui.ProductEditor.java

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
        @NonNull int[] grantResults) {
    if (requestCode == PERMISSION_REQUEST_READ_EXTERNAL_STORAGE) {
        if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
            startPickImageIntent();// w  w w.  jav  a  2  s . c o  m
        } else {
            Snackbar.make(findViewById(android.R.id.content), R.string.enable_persmission_from_settings,
                    Snackbar.LENGTH_INDEFINITE).setAction(R.string.enable, new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            Intent intent = new Intent();
                            intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
                            intent.addCategory(Intent.CATEGORY_DEFAULT);
                            intent.setData(Uri.parse("package:" + getPackageName()));
                            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                            intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
                            intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
                            startActivity(intent);
                        }
                    }).show();
        }
    }
}