Example usage for android.content Intent ACTION_DEFAULT

List of usage examples for android.content Intent ACTION_DEFAULT

Introduction

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

Prototype

String ACTION_DEFAULT

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

Click Source Link

Document

A synonym for #ACTION_VIEW , the "standard" action that is performed on a piece of data.

Usage

From source file:org.traccar.client.ShortcutActivity.java

private void setShortcutResult(String label, @DrawableRes int iconResId, String action) {
    Intent intent = new Intent(Intent.ACTION_DEFAULT, null, this, ShortcutActivity.class);
    intent.putExtra(EXTRA_ACTION, action);

    ShortcutInfoCompat shortcut = new ShortcutInfoCompat.Builder(this, action).setShortLabel(label)
            .setIcon(IconCompat.createWithResource(this, iconResId)).setIntent(intent).build();

    setResult(RESULT_OK, ShortcutManagerCompat.createShortcutResultIntent(this, shortcut));
}

From source file:org.ambientdynamix.core.HomeActivity.java

private void updateCheck() {
    new Thread(new Runnable() {
        @Override/* ww  w  . j a v  a 2s.  co  m*/
        public void run() {
            try {
                PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
                int verCode = pInfo.versionCode;
                DefaultHttpClient client = new DefaultHttpClient();
                HttpGet httpGet = new HttpGet("http://repo.smartphone-experimentation.eu/app/");
                try {
                    HttpResponse execute = client.execute(httpGet);
                    InputStream content = execute.getEntity().getContent();

                    BufferedReader buffer = new BufferedReader(new InputStreamReader(content));
                    StringBuilder builder = new StringBuilder();
                    String s = "";
                    while ((s = buffer.readLine()) != null) {
                        builder.append(s);
                    }

                    try {
                        if (verCode != Integer.parseInt(builder.toString())) {
                            {
                                final AlertDialog.Builder alertBuilder = new AlertDialog.Builder(activity);
                                alertBuilder.setTitle("Update Available");
                                alertBuilder.setMessage(
                                        "There is a newer version available for Organicity Experimentation. "
                                                + "Please click 'Update' to download and install the latest version.");
                                alertBuilder.setPositiveButton("Update", new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int id) {
                                        Intent browserIntent = new Intent(Intent.ACTION_DEFAULT, Uri.parse(
                                                "http://repo.smartphone-experimentation.eu/app/dynamix-framework-debug.apk"));
                                        startActivity(browserIntent);
                                    }
                                });
                                alertBuilder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int id) {
                                        // User cancelled the dialog
                                    }
                                });
                                runOnUiThread(new Runnable() {
                                    @Override
                                    public void run() {
                                        alertBuilder.show();
                                    }
                                });
                            }
                        }
                    } catch (Exception ignore) {
                    }
                } catch (Exception ignore) {
                }
            } catch (PackageManager.NameNotFoundException e) {
            }
        }
    }).start();
}

From source file:org.opendatakit.survey.activities.MainMenuActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    if (item.getItemId() == MENU_CLOUD_FORMS) {
        try {//from  w w w  . j a v  a 2 s.c  om
            Intent syncIntent = new Intent();
            syncIntent.setComponent(
                    new ComponentName(IntentConsts.Sync.APPLICATION_NAME, IntentConsts.Sync.ACTIVITY_NAME));
            syncIntent.setAction(Intent.ACTION_DEFAULT);
            Bundle bundle = new Bundle();
            bundle.putString(IntentConsts.INTENT_KEY_APP_NAME, appName);
            syncIntent.putExtras(bundle);
            this.startActivityForResult(syncIntent, SYNC_ACTIVITY_CODE);
        } catch (ActivityNotFoundException e) {
            WebLogger.getLogger(getAppName()).printStackTrace(e);
            Toast.makeText(this, R.string.sync_not_found, Toast.LENGTH_LONG).show();
        }
        return true;
    } else if (item.getItemId() == MENU_ABOUT) {
        swapToFragmentView(ScreenList.ABOUT_MENU);
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:org.opendatakit.survey.android.activities.MainMenuActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == MENU_FILL_FORM) {
        swapToFragmentView(ScreenList.FORM_CHOOSER);
        return true;
    } else if (item.getItemId() == MENU_PULL_FORMS) {
        swapToFragmentView(ScreenList.FORM_DOWNLOADER);
        return true;
    } else if (item.getItemId() == MENU_CLOUD_FORMS) {
        try {/*from  w ww.j  av a  2  s  .  c om*/
            Intent syncIntent = new Intent();
            syncIntent.setComponent(
                    new ComponentName("org.opendatakit.sync", "org.opendatakit.sync.activities.SyncActivity"));
            syncIntent.setAction(Intent.ACTION_DEFAULT);
            Bundle bundle = new Bundle();
            bundle.putString(APP_NAME, appName);
            syncIntent.putExtras(bundle);
            this.startActivityForResult(syncIntent, SYNC_ACTIVITY_CODE);
        } catch (ActivityNotFoundException e) {
            WebLogger.getLogger(getAppName()).printStackTrace(e);
            Toast.makeText(this, R.string.sync_not_found, Toast.LENGTH_LONG).show();
        }
        return true;
    } else if (item.getItemId() == MENU_MANAGE_FORMS) {
        swapToFragmentView(ScreenList.FORM_DELETER);
        return true;
    } else if (item.getItemId() == MENU_EDIT_INSTANCE) {
        swapToFragmentView(ScreenList.WEBKIT);
        return true;
    } else if (item.getItemId() == MENU_PUSH_FORMS) {
        swapToFragmentView(ScreenList.INSTANCE_UPLOADER_TABLE_CHOOSER);
        return true;
    } else if (item.getItemId() == MENU_PREFERENCES) {
        // PreferenceFragment missing from support library...
        Intent ig = new Intent(this, PreferencesActivity.class);
        // TODO: convert this activity into a preferences fragment
        ig.putExtra(APP_NAME, getAppName());
        startActivity(ig);
        return true;
    } else if (item.getItemId() == MENU_ADMIN_PREFERENCES) {
        String pw = PropertiesSingleton.getProperty(appName, AdminPreferencesActivity.KEY_ADMIN_PW);
        if (pw == null || "".equalsIgnoreCase(pw)) {
            Intent i = new Intent(getApplicationContext(), AdminPreferencesActivity.class);
            // TODO: convert this activity into a preferences fragment
            i.putExtra(APP_NAME, getAppName());
            startActivity(i);
        } else {
            createPasswordDialog();
        }
        return true;
    } else if (item.getItemId() == MENU_ABOUT) {
        swapToFragmentView(ScreenList.ABOUT_MENU);
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:org.path.episample.android.activities.MainMenuActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    /*// www.  j  a  v a 2  s.c  o  m
     * if (item.getItemId() == MENU_FILL_FORM) {
      swapToFragmentView(ScreenList.FORM_CHOOSER); return true; } else 
     */

    if (item.getItemId() == MENU_MAIN_MENU) {
        swapToFragmentView(ScreenList.MAIN_MENU);

        return true;
    } else if (item.getItemId() == MENU_PULL_FORMS) {
        swapToFragmentView(ScreenList.FORM_DOWNLOADER);
        return true;
    } else if (item.getItemId() == MENU_CLOUD_FORMS) {
        try {
            Intent syncIntent = new Intent();
            syncIntent.setComponent(
                    new ComponentName("org.path.sync", "org.opendatakit.sync.activities.SyncActivity"));
            syncIntent.setAction(Intent.ACTION_DEFAULT);
            Bundle bundle = new Bundle();
            bundle.putString(APP_NAME, appName);
            syncIntent.putExtras(bundle);
            this.startActivityForResult(syncIntent, SYNC_ACTIVITY_CODE);
        } catch (ActivityNotFoundException e) {
            WebLogger.getLogger(getAppName()).printStackTrace(e);
            Toast.makeText(this, R.string.sync_not_found, Toast.LENGTH_LONG).show();
        }
        return true;
    } else if (item.getItemId() == MENU_MANAGE_FORMS) {
        swapToFragmentView(ScreenList.FORM_DELETER);
        return true;
    } else if (item.getItemId() == MENU_EDIT_INSTANCE) {
        swapToFragmentView(ScreenList.WEBKIT);
        return true;
    } else if (item.getItemId() == MENU_PUSH_FORMS) {
        swapToFragmentView(ScreenList.INSTANCE_UPLOADER_TABLE_CHOOSER);
        return true;
    } else if (item.getItemId() == MENU_PREFERENCES) {
        // PreferenceFragment missing from support library...
        Intent ig = new Intent(this, PreferencesActivity.class);
        // TODO: convert this activity into a preferences fragment
        ig.putExtra(APP_NAME, getAppName());
        startActivity(ig);
        return true;
    } else if (item.getItemId() == MENU_ADMIN_PREFERENCES) {
        String pw = PropertiesSingleton.getProperty(appName, AdminPreferencesActivity.KEY_ADMIN_PW);
        if (pw == null || "".equalsIgnoreCase(pw)) {
            Intent i = new Intent(getApplicationContext(), AdminPreferencesActivity.class);
            // TODO: convert this activity into a preferences fragment
            i.putExtra(APP_NAME, getAppName());
            startActivity(i);
        } else {
            createPasswordDialog();
        }
        return true;
    } else if (item.getItemId() == MENU_BACKUP_CENSUS) {
        if (CensusUtil.getCount(this) == 0) {
            Toast.makeText(this, getString(R.string.census_db_empty), Toast.LENGTH_LONG).show();
        } else {
            BackupRestoreUtils.BackupResult result = BackupRestoreUtils.simpleBackup(this, getAppName());
            if (result.getSuccess() == true) {
                Toast.makeText(this, getString(R.string.backup_successful, result.getDatabaseFileName()),
                        Toast.LENGTH_LONG).show();
            } else {
                Toast.makeText(this, getString(R.string.backup_unsuccessful, result.getDatabaseFileName()),
                        Toast.LENGTH_LONG).show();
            }
        }
        return true;
    } else if (item.getItemId() == MENU_RESTORE_CENSUS) {
        swapToFragmentView(ScreenList.RESTORE_MODULE);
        return true;
    } else if (item.getItemId() == MENU_EDIT_CENSUS) {
        BackupRestoreUtils.backupCensus(Survey.getInstance().getApplicationContext(), "survey");
        swapToFragmentView(ScreenList.EDIT_CENSUS_MODULE);
        return true;
    } else if (item.getItemId() == MENU_REMOVE_CENSUS) {
        swapToFragmentView(ScreenList.REMOVE_CENSUS_MODULE);
        return true;
    } else if (item.getItemId() == MENU_MARK_CENSUS_AS_INVALID) {
        swapToFragmentView(ScreenList.INVALIDATE_CENSUS_MODULE);
        return true;
    } /*else if(item.getItemId() == MENU_SEND_REVEIVE_BLUETOOTH) {
      swapToFragmentView(ScreenList.SEND_RECEIVE_BLUETOOTH_MODULE);
      return true;
      }*/ else if (item.getItemId() == MENU_ABOUT) {
        swapToFragmentView(ScreenList.ABOUT_MENU);
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:android.content.pm.PackageParser.java

/**
 * Check if one of the IntentFilter as both actions DEFAULT / VIEW and a HTTP/HTTPS data URI
 *///  w  w w  .  j  a  v a 2  s  .  c  om
private static boolean hasDomainURLs(Package pkg) {
    if (pkg == null || pkg.activities == null)
        return false;
    final ArrayList<Activity> activities = pkg.activities;
    final int countActivities = activities.size();
    for (int n = 0; n < countActivities; n++) {
        Activity activity = activities.get(n);
        ArrayList<ActivityIntentInfo> filters = activity.intents;
        if (filters == null)
            continue;
        final int countFilters = filters.size();
        for (int m = 0; m < countFilters; m++) {
            ActivityIntentInfo aii = filters.get(m);
            if (!aii.hasAction(Intent.ACTION_VIEW))
                continue;
            if (!aii.hasAction(Intent.ACTION_DEFAULT))
                continue;
            if (aii.hasDataScheme(IntentFilter.SCHEME_HTTP) || aii.hasDataScheme(IntentFilter.SCHEME_HTTPS)) {
                return true;
            }
        }
    }
    return false;
}