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:net.sylvek.sharemyposition.ShareMyPosition.java

/**
 * @param location/*from  w  w w. j  a  v a 2  s.c  o m*/
 * @param extra
 * @param uuid
 * @param isTracked
 */
private void share(final double latitude, final double longitude, final Intent extra, final Intent toLaunch,
        final String body, final boolean isGeocodeAddress, final boolean isUrl, final boolean isNative,
        final boolean isLatLong, final boolean isTracked, final String uuid) {
    Executors.newCachedThreadPool().execute(new Runnable() {

        @Override
        public void run() {
            String msg = getMessage(latitude, longitude, body, isGeocodeAddress, isUrl, isNative, isLatLong,
                    isTracked, uuid);

            if (isTracked) {
                String url = getCurrentStaticLocationUrl(latitude, longitude, isNative, isTracked, uuid);
                startTracking(uuid, url, msg);
            }

            extra.addCategory(Intent.CATEGORY_DEFAULT)
                    .putExtra(Intent.EXTRA_SUBJECT, getString(R.string.subject))
                    .putExtra(Intent.EXTRA_TEXT, msg).putExtra("sms_body", msg);
            startActivity((toLaunch != null) ? toLaunch : extra);
            finish();
        }
    });
}

From source file:de.ub0r.android.callmeter.ui.prefs.Preferences.java

/**
 * Export data.//  ww  w.java2 s  . c  om
 * 
 * @param descr
 *            description of the exported rule set
 * @param fn
 *            one of the predefined file names from {@link DataProvider}.
 */
private void exportData(final String descr, final String fn) {
    if (descr == null) {
        final EditText et = new EditText(this);
        Builder builder = new Builder(this);
        builder.setView(et);
        builder.setCancelable(true);
        builder.setTitle(R.string.export_rules_descr);
        builder.setNegativeButton(android.R.string.cancel, null);
        builder.setPositiveButton(android.R.string.ok, new OnClickListener() {
            @Override
            public void onClick(final DialogInterface dialog, final int which) {
                Preferences.this.exportData(et.getText().toString(), fn);
            }
        });
        builder.show();
    } else {
        final ProgressDialog d = new ProgressDialog(this);
        d.setIndeterminate(true);
        d.setMessage(this.getString(R.string.export_progr));
        d.setCancelable(false);
        d.show();

        // run task in background
        final AsyncTask<Void, Void, String> task = // .
                new AsyncTask<Void, Void, String>() {
                    @Override
                    protected String doInBackground(final Void... params) {
                        if (fn.equals(DataProvider.EXPORT_RULESET_FILE)) {
                            return DataProvider.backupRuleSet(Preferences.this, descr);
                        } else if (fn.equals(DataProvider.EXPORT_LOGS_FILE)) {
                            return DataProvider.backupLogs(Preferences.this, descr);
                        } else if (fn.equals(DataProvider.EXPORT_NUMGROUPS_FILE)) {
                            return DataProvider.backupNumGroups(Preferences.this, descr);
                        } else if (fn.equals(DataProvider.EXPORT_HOURGROUPS_FILE)) {
                            return DataProvider.backupHourGroups(Preferences.this, descr);
                        }
                        return null;
                    }

                    @Override
                    protected void onPostExecute(final String result) {
                        Log.d(TAG, "export:\n" + result);
                        System.out.println("\n" + result);
                        d.dismiss();
                        if (result != null && result.length() > 0) {
                            Uri uri = null;
                            int resChooser = -1;
                            if (fn.equals(DataProvider.EXPORT_RULESET_FILE)) {
                                uri = DataProvider.EXPORT_RULESET_URI;
                                resChooser = R.string.export_rules_;
                            } else if (fn.equals(DataProvider.EXPORT_LOGS_FILE)) {
                                uri = DataProvider.EXPORT_LOGS_URI;
                                resChooser = R.string.export_logs_;
                            } else if (fn.equals(DataProvider.EXPORT_NUMGROUPS_FILE)) {
                                uri = DataProvider.EXPORT_NUMGROUPS_URI;
                                resChooser = R.string.export_numgroups_;
                            } else if (fn.equals(DataProvider.EXPORT_HOURGROUPS_FILE)) {
                                uri = DataProvider.EXPORT_HOURGROUPS_URI;
                                resChooser = R.string.export_hourgroups_;
                            }
                            final Intent intent = new Intent(Intent.ACTION_SEND);
                            intent.setType(DataProvider.EXPORT_MIMETYPE);
                            intent.putExtra(Intent.EXTRA_STREAM, uri);
                            intent.putExtra(Intent.EXTRA_SUBJECT, // .
                                    "Call Meter 3G export");
                            intent.addCategory(Intent.CATEGORY_DEFAULT);

                            try {
                                final File d = Environment.getExternalStorageDirectory();
                                final File f = new File(d, DataProvider.PACKAGE + File.separator + fn);
                                f.mkdirs();
                                if (f.exists()) {
                                    f.delete();
                                }
                                f.createNewFile();
                                FileWriter fw = new FileWriter(f);
                                fw.append(result);
                                fw.close();
                                // call an exporting app with the uri to the
                                // preferences
                                Preferences.this.startActivity(
                                        Intent.createChooser(intent, Preferences.this.getString(resChooser)));
                            } catch (IOException e) {
                                Log.e(TAG, "error writing export file", e);
                                Toast.makeText(Preferences.this, R.string.err_export_write, Toast.LENGTH_LONG)
                                        .show();
                            }
                        }
                    }
                };
        task.execute((Void) null);
    }
}

From source file:cn.edu.zafu.corepage.base.BaseActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_base);
    Intent mNewIntent = getIntent();/*from   w  ww  .j a v  a  2 s. com*/
    //?activity
    if (null != savedInstanceState) {
        loadActivitySavedData(savedInstanceState);
        //???
        //?SaveWithActivity
    }
    mHandler = new Handler(getMainLooper());
    //handler
    mCurrentInstance = new WeakReference<BaseActivity>(this);
    //?activity
    mActivities.add(mCurrentInstance);
    //?activityactivity
    printAllActivities();
    //?activity

    init(mNewIntent);
    //?activity
    IntentFilter filter = new IntentFilter();
    filter.addAction(CoreConfig.ACTION_EXIT_APP);
    filter.addCategory(Intent.CATEGORY_DEFAULT);
    CoreConfig.getLocalBroadcastManager().registerReceiver(mExitReceiver, filter);
    //?

    //?
    AnalyticsConfig.enableEncrypt(false);
    MobclickAgent.setDebugMode(true);
    MobclickAgent.openActivityDurationTrack(false);
    MobclickAgent.updateOnlineConfig(this);
}

From source file:tv.acfun.a63.ArticleActivity.java

@Override
public void onErrorResponse(VolleyError error) {
    setSupportProgressBarIndeterminateVisibility(false);
    if (error instanceof Article.InvalidArticleError) {
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.addCategory(Intent.CATEGORY_DEFAULT);
        intent.setData(Uri.parse("av://ac" + aid));
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        try {//w  w  w  . j  a  va2 s . c o  m
            startActivity(intent);
            finish();
        } catch (Exception e) {
            //http://www.acfun.tv/lite/v/#ac=1317054
            mWeb.loadUrl("http://" + ArticleApi.getDomainRoot(this) + "/lite/v/#ac=" + aid);
        }
    } else if (error instanceof ServerError) {
        mWeb.loadUrl("http://" + ArticleApi.getDomainRoot(this) + "/lite/v/#ac=" + aid);
    } else {
        showErrorDialog();
    }
}

From source file:com.custom.music.MusicBrowserActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    Cursor cursor;//from  ww  w .  ja  v  a2 s.c o  m
    Intent intent;
    switch (item.getItemId()) {
    case PLAY_ALL:
        String sortOrder_play_all = MediaStore.Audio.Media.DEFAULT_SORT_ORDER;
        if (MusicUtils.isMediaTitlePinyinKeyExist()) {
            sortOrder_play_all = "title_pinyin_key";
        }
        cursor = MusicUtils.query(this, MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
                new String[] { MediaStore.Audio.Media._ID }, MediaStore.Audio.Media.IS_MUSIC + "=1", null,
                /// M: add for chinese sorting
                sortOrder_play_all);
        if (cursor != null) {
            MusicUtils.playAll(this, cursor);
            cursor.close();
        }
        return true;
    case SHUFFLE_ALL:
        String sortOrder_shuffle_all = MediaStore.Audio.Media.DEFAULT_SORT_ORDER;
        if (MusicUtils.isMediaTitlePinyinKeyExist()) {
            sortOrder_shuffle_all = "title_pinyin_key";
        }
        cursor = MusicUtils.query(this, MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
                new String[] { MediaStore.Audio.Media._ID }, MediaStore.Audio.Media.IS_MUSIC + "=1", null,
                /// M: add for chinese sorting
                sortOrder_shuffle_all);
        if (cursor != null) {
            MusicUtils.shuffleAll(this, cursor);
            cursor.close();
        }
        return true;

    case EFFECTS_PANEL:
        return MusicUtils.startEffectPanel(this);

    case R.id.search:
        onSearchRequested();
        return true;

    case TrackBrowserActivity.ADD_FOLDER_TO_PLAY:
        intent = new Intent("com.mediatek.filemanager.DOWNLOAD_LOCATION");
        intent.addCategory(Intent.CATEGORY_DEFAULT);
        this.startActivityForResult(intent, TrackBrowserActivity.ADD_FOLDER_TO_PLAY);
        return true;

    case PlaylistBrowserActivity.ADD_FOLDER_AS_PLAYLIST:
        intent = new Intent("com.mediatek.filemanager.DOWNLOAD_LOCATION");
        intent.addCategory(Intent.CATEGORY_DEFAULT);
        this.startActivityForResult(intent, PlaylistBrowserActivity.ADD_FOLDER_AS_PLAYLIST);
        return true;

    case TrackBrowserActivity.ADD_SONG_TO_PLAY:
        intent = new Intent("com.mediatek.filemanager.ADD_FILE");
        intent.addCategory(Intent.CATEGORY_DEFAULT);
        this.startActivityForResult(intent, TrackBrowserActivity.ADD_SONG_TO_PLAY);
        return true;

    default:
        break;
    }
    return super.onOptionsItemSelected(item);
}

From source file:org.wso2.emm.agent.utils.CommonUtils.java

public static void registerSystemAppReceiver(Context context) {
    IntentFilter filter = new IntentFilter(Constants.SYSTEM_APP_BROADCAST_ACTION);
    filter.addCategory(Intent.CATEGORY_DEFAULT);
    SystemServiceResponseReceiver receiver = new SystemServiceResponseReceiver();
    context.registerReceiver(receiver, filter);
}

From source file:net.sylvek.sharemyposition.ShareMyPosition.java

/**
 * @param uuid//w  w w.ja  v a2s.c o  m
 */
private void startTracking(final String uuid, final String url, final String msg) {
    final Context context = getApplicationContext();

    // start the tracker
    sendBroadcast(
            new Intent(context, ShareByTracking.StartTracking.class).putExtra(ShareByTracking.UUID, uuid));

    // generate delete action
    final Intent deleteIntent = new Intent(context, ShareByTracking.StopTracking.class);
    final Intent t = new Intent(Intent.ACTION_SEND).setType("text/plain").addCategory(Intent.CATEGORY_DEFAULT)
            .putExtra(Intent.EXTRA_SUBJECT, getString(R.string.subject)).putExtra(Intent.EXTRA_TEXT, msg)
            .putExtra("sms_body", msg);
    final PendingIntent delete = PendingIntent.getBroadcast(context, 0, deleteIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);

    // generate content action
    final Intent contentIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    final PendingIntent intent = PendingIntent.getActivity(context, 0, contentIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);

    // generate share action
    final Intent shareIntent = Intent.createChooser(t, getString(R.string.app_name))
            .addCategory(Intent.CATEGORY_DEFAULT);
    final PendingIntent share = PendingIntent.getActivity(context, 0, shareIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);

    // show notification
    final NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
            .setSmallIcon(R.drawable.notification).setContentTitle(getString(R.string.app_name))
            .setOngoing(IS_JELLY_BEAN_OR_GREATER).setDeleteIntent(delete)
            .addAction(android.R.drawable.ic_menu_share, getString(R.string.share_it), share)
            .addAction(android.R.drawable.ic_menu_close_clear_cancel, getString(R.string.track_stop_it), delete)
            .setContentText(getString(R.string.track_location_notification)).setContentIntent(intent)
            .setUsesChronometer(true);
    final NotificationManager notificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);
    notificationManager.notify(R.string.app_name, mBuilder.build());
}

From source file:com.tenforwardconsulting.cordova.BackgroundGeolocationPlugin.java

public void showAppSettings() {
    Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent.setData(Uri.parse("package:" + getContext().getPackageName()));
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
    intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
    getContext().startActivity(intent);//www  . j  a  v  a2  s  . com
}

From source file:com.just.agentweb.AgentWebUtils.java

static Intent getIntentCaptureCompat(Context context, File file) {
    Intent mIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    Uri mUri = getUriFromFile(context, file);
    mIntent.addCategory(Intent.CATEGORY_DEFAULT);
    mIntent.putExtra(MediaStore.EXTRA_OUTPUT, mUri);
    return mIntent;
}

From source file:com.bridgeconn.autographago.ui.activities.SettingsActivity.java

@Override
public void onRequestPermissionsResult(final int requestCode, String[] permissions, int[] grantResults) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);

    switch (requestCode) {
    case Constants.RequestCodes.PERMISSION_STORAGE: {
        if (ContextCompat.checkSelfPermission(SettingsActivity.this,
                Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {

            startDownload(downloadUrl);//ww w .j  av a 2  s .co m

        } else {
            String positiveButton;
            if (!shouldShowRequestPermissionRationale(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
                positiveButton = getString(R.string.take_me_to_settings).toUpperCase();
            } else {
                positiveButton = getString(R.string.try_again).toUpperCase();
            }
            AlertDialog.Builder builder = new AlertDialog.Builder(SettingsActivity.this,
                    R.style.DialogThemeLight);
            builder.setMessage(getString(R.string.storage_permission_message));
            builder.setPositiveButton(positiveButton, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    if (!shouldShowRequestPermissionRationale(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
                        Intent myAppSettings = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
                                Uri.parse("package:" + SettingsActivity.this.getPackageName()));
                        myAppSettings.addCategory(Intent.CATEGORY_DEFAULT);
                        startActivityForResult(myAppSettings, Constants.RequestCodes.APP_SETTINGS_STORAGE);
                    } else {
                        ActivityCompat.requestPermissions(SettingsActivity.this,
                                new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, requestCode);
                    }
                }
            });
            builder.setNegativeButton(getString(R.string.cancel).toUpperCase(),
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                        }
                    });
            builder.show();
        }
        break;
    }
    }
}