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.montanafoodhub.base.Hub.java

protected void broadcastRefresh(Context context, HubType type) {
    Intent intent = new Intent();
    intent.setAction(HUB_DATA_REFRESH);/*  w  w  w .ja  va2 s  .co m*/
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent.putExtra(EXTRA_HUB_TYPE, type);
    LocalBroadcastManager.getInstance(context).sendBroadcast(intent);

    Log.w(HubInit.logTag, "broadcast sent");
}

From source file:sample.multithreading.NetworkDownloadService.java

void broadcastIntentWithState(int paramInt) {
    Intent localIntent = new Intent();
    localIntent.setAction(BROADCAST_ACTION);
    localIntent.putExtra(EXTRA_STATUS, paramInt);
    localIntent.addCategory(Intent.CATEGORY_DEFAULT);
    mBroadcastManager.sendBroadcast(localIntent);
}

From source file:com.phonegap.plugins.barcodescanner.BarcodeScanner.java

/**
 * Starts an intent to scan and decode a barcode.
 *//*from  w w  w  . java2  s  .  c om*/
public void scan() {
    Intent intentScan = new Intent("com.phonegap.plugins.barcodescanner.SCAN");
    intentScan.addCategory(Intent.CATEGORY_DEFAULT);

    this.ctx.startActivityForResult((Plugin) this, intentScan, REQUEST_CODE);

}

From source file:org.apache.cordova.plugins.barcodescanner.BarcodeScanner.java

/**
 * Starts an intent to scan and decode a barcode.
 *//*www  .j  a va 2 s.  co m*/
public void scan() {
    Intent intentScan = new Intent("org.apache.cordova.plugins.barcodescanner.SCAN");
    intentScan.addCategory(Intent.CATEGORY_DEFAULT);

    this.ctx.startActivityForResult((Plugin) this, intentScan, REQUEST_CODE);
}

From source file:com.galois.qrstream.lib.DecodeThread.java

private Intent buildIntent(Job message) throws IOException {
    Intent i = new Intent();
    i.setAction(Intent.ACTION_SEND);//from   w  w w.java 2  s  . c o  m
    i.addCategory(Intent.CATEGORY_DEFAULT);
    String mimeType = message.getMimeType();
    i.setType(mimeType);

    if (mimeType.equals("text/plain")) {
        String msg = new String(message.getData());
        i.putExtra(Intent.EXTRA_TEXT, msg);
    } else {
        // content that is not text uses the filesystem to store the data
        // (when sharing with a new local app)
        File dataLoc = storeData(message);

        if (mimeType.startsWith("image/")) {
            String path = Images.Media.insertImage(context.getContentResolver(), dataLoc.getPath(),
                    message.getTitle(), null);
            Uri imageUri = Uri.parse(path);
            i.putExtra(Intent.EXTRA_STREAM, imageUri);

            // we can delete the temporary location in this case, since the file has been saved
            // to the media store.
            // In the other cases, the receiver has to handle the content of the temp file before
            // it can be deleted -- but we will never know if/when that happens.
            dataLoc.delete();
        } else if (mimeType.equals(Constants.MIME_TYPE_TEXT_NOTE)) {
            String json = new String(message.getData());
            try {
                JSONObject note = new JSONObject(json);
                i.putExtra(Intent.EXTRA_TEXT, note.getString(Intent.EXTRA_TEXT));
                i.putExtra(Intent.EXTRA_SUBJECT, note.getString(Intent.EXTRA_SUBJECT));
                i.setType("text/plain");
            } catch (JSONException e) {
                e.printStackTrace();
            }
        } else {
            i.putExtra(Intent.EXTRA_STREAM, dataLoc.toURI());
        }
    }
    return i;
}

From source file:com.villetainio.travelcardreminder.activities.MainActivity.java

public static void setupForegroundDispatch(final Activity activity, NfcAdapter adapter) {
    final Intent intent = new Intent(activity.getApplicationContext(), ReadCardActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
    final PendingIntent pendingIntent = PendingIntent.getActivity(activity.getApplicationContext(), 0, intent,
            0);//from ww  w . 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("*/*"); //TODO Use only needed MIME based dispatches.
    } catch (MalformedMimeTypeException e) {
        throw new RuntimeException("MIME type not supported.");
    }

    adapter.enableForegroundDispatch(activity, pendingIntent, filters, techList);
}

From source file:com.example.android.threadsample.BroadcastNotifier.java

/**
 * Uses LocalBroadcastManager to send an {@link String} containing a logcat message.
 * {@link Intent} has the action {@code BROADCAST_ACTION} and the category {@code DEFAULT}.
 *
 * @param logData a {@link String} to insert into the log.
 *//*from   w w  w .j av a  2s .co m*/
public void notifyProgress(String logData) {

    Intent localIntent = new Intent();

    // The Intent contains the custom broadcast action for this app
    localIntent.setAction(Constants.BROADCAST_ACTION);

    localIntent.putExtra(Constants.EXTENDED_DATA_STATUS, -1);

    // Puts log data into the Intent
    localIntent.putExtra(Constants.EXTENDED_STATUS_LOG, logData);
    localIntent.addCategory(Intent.CATEGORY_DEFAULT);

    // Broadcasts the Intent
    mBroadcaster.sendBroadcast(localIntent);

}

From source file:com.facebook.react.tests.ShareTestCase.java

public void testShowBasicShareDialog() {
    final WritableMap content = new WritableNativeMap();
    content.putString("message", "Hello, ReactNative!");
    final WritableMap options = new WritableNativeMap();

    IntentFilter intentFilter = new IntentFilter(Intent.ACTION_CHOOSER);
    intentFilter.addCategory(Intent.CATEGORY_DEFAULT);
    ActivityMonitor monitor = getInstrumentation().addMonitor(intentFilter, null, true);

    getTestModule().showShareDialog(content, options);

    waitForBridgeAndUIIdle();//  w  w w  . j  a v  a2  s.  co m
    getInstrumentation().waitForIdleSync();

    assertEquals(1, monitor.getHits());
    assertEquals(1, mRecordingModule.getOpened());
    assertEquals(0, mRecordingModule.getErrors());

}

From source file:cn.edu.zafu.corepage.core.CoreConfig.java

/**
 * ???// w w  w . j a v a  2s.  co m
 */
public void exitApp() {
    Intent intent = new Intent();
    intent.setAction(CoreConfig.ACTION_EXIT_APP);
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    getLocalBroadcastManager().sendBroadcast(intent);
    BaseActivity.unInit();
}

From source file:cn.androidy.network.download.BroadcastNotifier.java

public void notifyProgress(int progress, String msg) {

    Intent localIntent = new Intent();

    // The Intent contains the custom broadcast action for this app
    localIntent.setAction(Constants.BROADCAST_ACTION);

    localIntent.putExtra(Constants.EXTENDED_DATA_STATUS, progress);
    localIntent.putExtra(Constants.EXTENDED_DATA_MSG, msg);
    localIntent.addCategory(Intent.CATEGORY_DEFAULT);

    // Broadcasts the Intent
    mBroadcaster.sendBroadcast(localIntent);

}