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:org.linkdroid.BroadcastReceiverService.java

private void enableSmsReceiver() {
    final IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(ACTION_SMS_RECEIVED);
    intentFilter.addCategory(Intent.CATEGORY_DEFAULT);
    registerReceiver(smsReceiver, intentFilter);
    Log.d(TAG, "registered SMS Receiver");
}

From source file:org.videolan.vlc.util.Permissions.java

private static Dialog createDialogCompat(final Activity activity, boolean exit) {
    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(activity)
            .setTitle(activity.getString(R.string.allow_storage_access_title))
            .setMessage(activity.getString(R.string.allow_storage_access_description))
            .setIcon(android.R.drawable.ic_dialog_alert).setPositiveButton(
                    activity.getString(R.string.permission_ask_again), new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int whichButton) {
                            SharedPreferences settings = PreferenceManager
                                    .getDefaultSharedPreferences(activity);
                            if (!settings.getBoolean("user_declined_storage_access", false))
                                requestStoragePermission(activity);
                            else {
                                Intent i = new Intent();
                                i.setAction("android.settings.APPLICATION_DETAILS_SETTINGS");
                                i.addCategory(Intent.CATEGORY_DEFAULT);
                                i.setData(Uri
                                        .parse("package:" + VLCApplication.getAppContext().getPackageName()));
                                i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                                try {
                                    activity.startActivity(i);
                                } catch (Exception ex) {
                                }/*from   ww w  .  java2 s.c o m*/
                            }
                            SharedPreferences.Editor editor = settings.edit();
                            editor.putBoolean("user_declined_storage_access", true);
                            editor.apply();
                        }
                    });
    if (exit) {
        dialogBuilder.setNegativeButton(activity.getString(R.string.exit_app),
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        activity.finish();
                    }
                }).setCancelable(false);
    }
    return dialogBuilder.show();
}

From source file:com.ratebeer.android.gui.fragments.SearchFragment.java

@OptionsItem(R.id.menu_scanbarcode)
protected void startScanner() {
    // Test to see if the ZXing barcode scanner is available that can handle the SCAN intent
    Intent scan = new Intent(SCAN_INTENT);
    scan.addCategory(Intent.CATEGORY_DEFAULT);
    scan.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    if (ActivityUtil.isIntentAvailable(getActivity(), scan)) {
        // Ask the barcode scanner to allow the user to scan some code
        try {/*from  w w  w  . j a  va2s.co m*/
            startActivityForResult(scan, ACTIVITY_BARCODE);
        } catch (Exception e) {
            // Can't start the barcode scanner, for example with a SecurityException, even though it is there
            Crouton.makeText(getActivity(), R.string.app_notsupported, Style.INFO).show();
        }
    } else {
        // Show a message if the user should install the barcode scanner for this feature
        new ConfirmDialogFragment(new OnDialogResult() {
            @Override
            public void onConfirmed() {
                Intent install = new Intent(Intent.ACTION_VIEW, SCANNER_MARKET_URI);
                if (ActivityUtil.isIntentAvailable(getActivity(), install)) {
                    startActivity(install);
                } else {
                    Crouton.makeText(getActivity(), R.string.app_nomarket, Style.INFO).show();
                }
            }
        }, R.string.app_scannernotfound, "").show(getFragmentManager(), "installscanner");
    }
}

From source file:vn.co.taxinet.mobile.newactivity.MapActivity.java

private void initialize() {
    // startLocationUpdates();
    receiver = new mHandleMessageReceiver();
    // set up broadcast receiver
    IntentFilter filter = new IntentFilter(Constants.BroadcastAction.DISPLAY_REQUEST);
    filter.addCategory(Intent.CATEGORY_DEFAULT);
    // receiver = new mHandleMessageReceiver();
    registerReceiver(receiver, filter);//from ww w . ja  va 2 s .  c om

    handler = new DatabaseHandler(this);
}

From source file:com.trail.octo.Identity.java

public void requestCameraPermission() {
    if (ContextCompat.checkSelfPermission(this,
            Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
        // Should we show an explanation?
        if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.CAMERA)) {
            Log.e("Check", "Go To Settings");
            Toast.makeText(getApplicationContext(), "OCTO requires this Permission to upload Images!",
                    Toast.LENGTH_LONG).show();
            final Intent i = new Intent();
            i.setAction(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
            i.addCategory(Intent.CATEGORY_DEFAULT);
            i.setData(Uri.parse("package:" + Identity.this.getPackageName()));
            i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            i.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
            i.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
            startActivity(i);// Show an expanation to the user *asynchronously* -- don't block
            // this thread waiting for the user's response! After the user
            // sees the explanation, try again to request the permission.

        } else {/*  w  w w .jav a  2  s  .  c o  m*/

            // No explanation needed, we can request the permission.

            Log.e("Check", "Requesting");
            ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.CAMERA },
                    REQUEST_CAMERA_PERMISSION);

            // MY_PERMISSIONS_REQUEST_READ_CONTACTS is an
            // app-defined int constant. The callback method gets the
            // result of the request.
        }
    } else {
        Log.e("Check", "Already Granted");
        //Already Permission Granted
        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        startActivityForResult(intent, 1);
    }
}

From source file:sample.multithreading.DownloaderActivity.java

@Override
public void onCreate(Bundle paramBundle) {
    super.onCreate(paramBundle);
    getWindow().setFlags(//from ww w .j  ava 2  s.  co  m
            WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
                    | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR,
            WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
                    | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR);
    CompatibleActionBar localCompatibleActionBar = getCompatibleActionBar();
    localCompatibleActionBar.requestOverlayMode();
    this.mMainView = getLayoutInflater().inflate(R.layout.fragmenthost, null);
    setContentView(this.mMainView);
    localCompatibleActionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.actionbarbg));
    localCompatibleActionBar.setDisplayUseLogoEnabled(true);
    localCompatibleActionBar.setLogo(R.drawable.picasalogo);
    View localView = getLayoutInflater().inflate(R.layout.progress, null);
    localCompatibleActionBar.setCustomView(localView);
    this.mActionBarProgressText = ((TextView) localView.findViewById(R.id.actionBarProgressText));
    IntentFilter localIntentFilter = new IntentFilter(NetworkDownloadService.BROADCAST_ACTION);
    localIntentFilter.addCategory(Intent.CATEGORY_DEFAULT);
    this.mReceiver = new ResponseReceiver();
    LocalBroadcastManager.getInstance(this).registerReceiver(this.mReceiver, localIntentFilter);
    IntentFilter fragmentIntentFilter = new IntentFilter(ACTION_VIEW_IMAGE);
    fragmentIntentFilter.addDataScheme("http");
    LocalBroadcastManager.getInstance(this).registerReceiver(mIntentReceiver, fragmentIntentFilter);

    fragmentIntentFilter = new IntentFilter(ACTION_ZOOM_IMAGE);
    LocalBroadcastManager.getInstance(this).registerReceiver(mIntentReceiver, fragmentIntentFilter);

    FragmentManager localFragmentManager = getSupportFragmentManager();
    this.mSideBySide = getResources().getBoolean(R.bool.sideBySide);
    this.mHideNavigation = getResources().getBoolean(R.bool.hideNavigation);
    localFragmentManager.addOnBackStackChangedListener(this);
    if (paramBundle == null) {
        FragmentTransaction localFragmentTransaction = localFragmentManager.beginTransaction();
        localFragmentTransaction.add(R.id.fragmentHost, new ThumbnailFragment(), THUMBNAIL_FRAGMENT_TAG);
        localFragmentTransaction.commit();
    } else {
        mFullScreen = paramBundle.getBoolean(EXTRA_FULLSCREEN);
        setFullScreen(mFullScreen);
        mPreviousStackCount = localFragmentManager.getBackStackEntryCount();
    }
}

From source file:com.github.howeyc.slideshow.activities.MainActivity.java

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

    debug("onResume");
    // refresh toolbar options (hide/show downloadNow)
    supportInvalidateOptionsMenu();//from  w  w w  .j av a 2s .c om
    if (AppData.getFirstAppStart()) {
        AppData.setFirstAppStart(false);
        AppData.setTutorial(true);
    }

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    tutorial();
    // get localBroadcastManager instance to receive localBroadCasts
    if (broadcastManager == null) {
        broadcastManager = LocalBroadcastManager.getInstance(getApplicationContext());
    }
    // register broadcast receiver for UI update from service
    if (receiver == null) {
        IntentFilter filter = new IntentFilter();
        filter.addAction(Keys.ACTION_DOWNLOAD_FINISHED);
        filter.addAction(Keys.ACTION_PROGRESSUPDATE);
        filter.addCategory(Intent.CATEGORY_DEFAULT);
        receiver = new ResponseReceiver();
        broadcastManager.registerReceiver(receiver, filter);
    }

    if (GlobalPhoneFuncs.getFileList(AppData.getImagePath()).size() > 0) {
        if (!AppData.getImagePath().equals(mOldPath) || mOldRecursive != AppData.getRecursiveSearch()) {
            loadAdapter();
        }
    }

    updateFileList();

    // start on the page we left in onPause, unless it was the first or last picture (as this freezes the slideshow
    if (currentPage < pager.getAdapter().getCount() - 1 && currentPage > 0) {
        pager.setCurrentItem(currentPage);
    }

    setUpSlideShow();

    if (AppData.getSlideshow() && !paused) {
        startSlideshowCountDown();
    }
}

From source file:com.futureplatforms.kirin.extensions.localnotifications.LocalNotificationsBackend.java

@SuppressWarnings("deprecation")
public Notification createNotification(Bundle settings, JSONObject obj) {

    // notifications[i] = api.normalizeAPI({
    // 'string': {
    // mandatory: ['title', 'body'],
    // defaults: {'icon':'icon'}
    // },/*from  w w  w. j  av  a 2s . co  m*/
    //
    // 'number': {
    // mandatory: ['id', 'timeMillisSince1970'],
    // // the number of ms after which we start prioritising more recent
    // things above you.
    // defaults: {'epsilon': 1000 * 60 * 24 * 365}
    // },
    //
    // 'boolean': {
    // defaults: {
    // 'vibrate': false,
    // 'sound': false
    // }
    // }

    int icon = settings.getInt("notification_icon", -1);
    if (icon == -1) {
        Log.e(C.TAG, "Need a notification_icon resource in the meta-data of LocalNotificationsAlarmReceiver");
        return null;
    }

    Notification n = new Notification();
    n.icon = icon;
    n.flags = Notification.FLAG_ONLY_ALERT_ONCE | Notification.FLAG_AUTO_CANCEL;
    long alarmTime = obj.optLong("timeMillisSince1970");
    long displayTime = obj.optLong("displayTimestamp", alarmTime);
    n.when = displayTime;
    n.tickerText = obj.optString("body");
    n.setLatestEventInfo(mContext, obj.optString("title"), obj.optString("body"), null);

    if (obj.optBoolean("vibrate")) {
        n.defaults |= Notification.DEFAULT_VIBRATE;
    }
    if (obj.optBoolean("sound")) {
        n.defaults |= Notification.DEFAULT_SOUND;
    }

    String uriString = settings.getString("content_uri_prefix");
    if (uriString == null) {
        Log.e(C.TAG, "Need a content_uri_prefix in the meta-data of LocalNotificationsAlarmReceiver");
        return null;
    }

    if (uriString.contains("%d")) {
        uriString = String.format(uriString, obj.optInt("id"));
    }
    Uri uri = Uri.parse(uriString);

    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_VIEW);
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent.setData(uri);
    n.contentIntent = PendingIntent.getActivity(mContext, 23, intent, PendingIntent.FLAG_ONE_SHOT);
    return n;
}

From source file:com.dimasdanz.kendalipintu.NFCOpenDoorActivity.java

public static void setupForegroundDispatch(final Activity activity, NfcAdapter adapter) {
    final Intent intent = new Intent(activity.getApplicationContext(), activity.getClass());
    intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);

    final PendingIntent pendingIntent = PendingIntent.getActivity(activity.getApplicationContext(), 0, intent,
            0);//from w  ww . j  a v a 2s.  c om

    IntentFilter[] filters = new IntentFilter[1];
    String[][] techList = new String[][] {};
    filters[0] = new IntentFilter();
    filters[0].addAction(NfcAdapter.ACTION_NDEF_DISCOVERED);
    filters[0].addCategory(Intent.CATEGORY_DEFAULT);
    try {
        filters[0].addDataType(MIME_TEXT_PLAIN);
    } catch (MalformedMimeTypeException e) {
        throw new RuntimeException("Check your mime type.");
    }
    adapter.enableForegroundDispatch(activity, pendingIntent, filters, techList);
}

From source file:com.enstage.wibmo.sdk.inapp.InAppInitActivity.java

public static void startInAppFlowInApp(Activity activity, W2faInitRequest w2faInitRequest,
        W2faInitResponse w2faInitResponse) {
    Intent intent = new Intent(WibmoSDK.getWibmoIntentActionPackage() + ".InApp");
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent.putExtra("W2faInitRequest", w2faInitRequest);
    intent.putExtra("W2faInitResponse", w2faInitResponse);

    /*//ww  w .j av a 2  s  . com
    String targetAppPackage = WibmoSDK.getWibmoPackage();
    boolean flag = WibmoSDK.isPackageExisted(activity, targetAppPackage);
    if (flag==false) {
    WibmoSDK.showDownloadDialog(activity);
    }
    */
    if (readyPackage != null) {
        intent.setPackage(readyPackage);
    }

    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    //intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); //causes to iap to be cancelled when app returned by icon launch

    activity.startActivityForResult(intent, WibmoSDK.REQUEST_CODE_IAP_2FA);
}