Example usage for android.content Intent ACTION_DELETE

List of usage examples for android.content Intent ACTION_DELETE

Introduction

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

Prototype

String ACTION_DELETE

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

Click Source Link

Document

Activity Action: Delete the given data from its container.

Usage

From source file:org.wso2.emm.agent.api.ApplicationManager.java

/**
 * Removes an application from the device.
 * @param packageName - Application package name should be passed in as a String.
 *///w  ww  .jav  a  2  s. c o  m
public void uninstallApplication(String packageName) {
    if (packageName != null
            && !packageName.contains(resources.getString(R.string.application_package_prefix))) {
        packageName = resources.getString(R.string.application_package_prefix) + packageName;
    }

    Uri packageURI = Uri.parse(packageName);
    Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI);
    uninstallIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(uninstallIntent);
}

From source file:edu.mit.mobile.android.livingpostcards.CardViewActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.share:
        send();/*from   ww w . j  a  v  a  2 s .c  o m*/
        return true;

    case android.R.id.home: {
        NavUtils.navigateUpFromSameTask(this);
    }
        return true;

    case R.id.edit:
        startActivity(new Intent(Intent.ACTION_EDIT, mCard));
        return true;

    case R.id.delete:
        startActivityForResult(new Intent(Intent.ACTION_DELETE, mCard), REQUEST_DELETE);
        return true;

    default:
        return false;
    }
}

From source file:org.androidsoft.app.permission.ui.ApplicationFragment.java

/**
 * Uninstall the application/*from   ww  w.j ava2s  .c o m*/
 */
private void uninstall() {
    String uri = "package:" + mPackageName;
    Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, Uri.parse(uri));
    startActivity(uninstallIntent);

    ApplicationChangesService.notifyListeners();
}

From source file:at.wada811.utils.IntentUtils.java

/**
 * ???Intent??/*from   www  .j a  v a  2 s.  co  m*/
 *
 * @param packageName
 */
public static Intent createOpenUninstallIntent(String packageName) {
    return new Intent(Intent.ACTION_DELETE, Uri.fromParts("package", packageName, null));
}

From source file:com.secupwn.aimsicd.ui.activities.MainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    deviceFragment = new DeviceFragment();
    cellInfoFragment = new CellInfoFragment();
    atCommandFragment = new AtCommandFragment();
    dbViewerFragment = new DbViewerFragment();
    mapFragment = new MapFragment();

    mNavConf = new DrawerMenuActivityConfiguration.Builder(this).build();

    mDrawerLayout = (DrawerLayout) findViewById(mNavConf.getDrawerLayoutId());
    mDrawerList = (ListView) findViewById(mNavConf.getLeftDrawerId());
    mActionBar = getSupportActionBar();/*from w  w w .  ja va  2s  . c o m*/
    mTitle = getTitle();
    mDrawerTitle = getTitle();

    mDrawerList.setAdapter(mNavConf.getBaseAdapter());

    mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
            mDrawerLayout, /* DrawerLayout object */
            R.string.drawer_open, /* "open drawer" description */
            R.string.drawer_close /* "close drawer" description */
    ) {
        public void onDrawerClosed(View view) {
            super.onDrawerClosed(view);
            mActionBar.setTitle(mTitle);
            invalidateOptionsMenu();
        }

        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            mActionBar.setTitle(mDrawerTitle);
            invalidateOptionsMenu();
        }
    };

    // Set the drawer toggle as the DrawerListener
    mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
    mDrawerLayout.setDrawerListener(mDrawerToggle);
    mActionBar.setDisplayHomeAsUpEnabled(true);
    mActionBar.setHomeButtonEnabled(true);

    prefs = getSharedPreferences(AimsicdService.SHARED_PREFERENCES_BASENAME, 0);

    /* Pref listener to enable sms detection on pref change   */
    prefListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
        public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
            if (key.equals(getString(R.string.adv_user_root_pref_key))) {
                SmsDetection();
            }

        }
    };
    prefs.registerOnSharedPreferenceChangeListener(prefListener);

    mDisclaimerAccepted = getResources().getString(R.string.disclaimer_accepted);

    if (!prefs.getBoolean(mDisclaimerAccepted, false)) {
        final AlertDialog.Builder disclaimer = new AlertDialog.Builder(this).setTitle(R.string.disclaimer_title)
                .setMessage(R.string.disclaimer)
                .setPositiveButton(R.string.text_agree, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        prefsEditor = prefs.edit();
                        prefsEditor.putBoolean(mDisclaimerAccepted, true);
                        prefsEditor.apply();
                        startService();
                    }
                }).setNegativeButton(R.string.text_disagree, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        prefsEditor = prefs.edit();
                        prefsEditor.putBoolean(mDisclaimerAccepted, false);
                        prefsEditor.apply();
                        Uri packageUri = Uri.parse("package:com.SecUpwN.AIMSICD");
                        Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageUri);
                        startActivity(uninstallIntent);
                        finish();
                        if (mAimsicdService != null) {
                            mAimsicdService.onDestroy();
                        }
                    }
                });

        AlertDialog disclaimerAlert = disclaimer.create();
        disclaimerAlert.show();
    } else {
        startService();
    }
}

From source file:com.emotiona.study.listviewpage.SwipeMenuListViewFragment.java

private void delete(ApplicationInfo item) {
    // delete app
    try {//from   w  w  w  . ja v  a  2 s  .c o m
        Intent intent = new Intent(Intent.ACTION_DELETE);
        intent.setData(Uri.fromParts("package", item.packageName, null));
        startActivity(intent);
    } catch (Exception e) {
    }
}

From source file:com.SecUpwN.AIMSICD.AIMSICD.java

/**
 * Called when the activity is first created.
 *//*w ww  .ja v  a  2s. co m*/
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    getWindow().requestFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    mNavConf = getNavDrawerConfiguration();

    setContentView(mNavConf.getMainLayout());

    mDrawerLayout = (DrawerLayout) findViewById(mNavConf.getDrawerLayoutId());
    mDrawerList = (ListView) findViewById(mNavConf.getLeftDrawerId());
    mActionBar = getActionBar();
    mTitle = mDrawerTitle = getTitle();

    mDrawerList.setAdapter(mNavConf.getBaseAdapter());

    mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
            mDrawerLayout, /* DrawerLayout object */
            R.drawable.ic_drawer, /* nav drawer icon to replace 'Up' caret */
            R.string.drawer_open, /* "open drawer" description */
            R.string.drawer_close /* "close drawer" description */
    ) {

        /** Called when a drawer has settled in a completely closed state. */
        public void onDrawerClosed(View view) {
            super.onDrawerClosed(view);
            mActionBar.setTitle(mTitle);
            invalidateOptionsMenu();
        }

        /** Called when a drawer has settled in a completely open state. */
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            mActionBar.setTitle(mDrawerTitle);
            invalidateOptionsMenu();
        }
    };

    // Set the drawer toggle as the DrawerListener
    mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
    mDrawerLayout.setDrawerListener(mDrawerToggle);
    mActionBar.setDisplayHomeAsUpEnabled(true);
    mActionBar.setHomeButtonEnabled(true);

    mProgressBar = (ProgressBar) findViewById(R.id.progressBar);

    prefs = mContext.getSharedPreferences(AimsicdService.SHARED_PREFERENCES_BASENAME, 0);

    mDisclaimerAccepted = getResources().getString(R.string.disclaimer_accepted);

    if (!prefs.getBoolean(mDisclaimerAccepted, false)) {
        final AlertDialog.Builder disclaimer = new AlertDialog.Builder(this).setTitle(R.string.disclaimer_title)
                .setMessage(R.string.disclaimer)
                .setPositiveButton(R.string.text_agree, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        prefsEditor = prefs.edit();
                        prefsEditor.putBoolean(mDisclaimerAccepted, true);
                        prefsEditor.apply();
                        startService();
                    }
                }).setNegativeButton(R.string.text_disagree, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        prefsEditor = prefs.edit();
                        prefsEditor.putBoolean(mDisclaimerAccepted, false);
                        prefsEditor.apply();
                        Uri packageUri = Uri.parse("package:com.SecUpwN.AIMSICD");
                        Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageUri);
                        startActivity(uninstallIntent);
                        finish();
                        if (mAimsicdService != null)
                            mAimsicdService.onDestroy();
                    }
                });

        AlertDialog disclaimerAlert = disclaimer.create();
        disclaimerAlert.show();
    } else {
        startService();
    }
}

From source file:org.klnusbaum.udj.PlaylistFragment.java

private void removeSong(int position) {
    ActivePlaylistEntry toRemove = getItemAtPosition(position);
    Log.d(TAG, "Removing song with id " + toRemove.getSong().getId());
    Intent removeSongIntent = new Intent(Intent.ACTION_DELETE, Constants.PLAYLIST_URI, getActivity(),
            PlaylistSyncService.class);
    removeSongIntent.putExtra(Constants.ACCOUNT_EXTRA, account);
    removeSongIntent.putExtra(Constants.LIB_ID_EXTRA, toRemove.getSong().getId());
    getActivity().startService(removeSongIntent);
    playlistAdapter.removeItem(toRemove);
}

From source file:com.phonegap.bossbolo.plugin.BoloPlugin.java

public void uninstallBPP() {
    final String packageName = "com.bossbolo.bppapp";
    final CordovaPlugin currentPlugin = (CordovaPlugin) this;
    try {//www.  j av a2s. co  m
        ApplicationInfo info = this.cordova.getActivity().getPackageManager().getApplicationInfo(packageName,
                PackageManager.GET_UNINSTALLED_PACKAGES);
        new AlertDialog.Builder(this.cordova.getActivity()).setTitle("??").setMessage(
                "?\n    ?B++???B++????B++????\n    ???")
                .setPositiveButton("", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialoginterface, int i) {
                        Intent intent = new Intent();
                        intent.setAction(Intent.ACTION_DELETE);
                        intent.setData(Uri.parse("package:" + packageName));
                        currentPlugin.cordova.startActivityForResult(currentPlugin, intent, 2298816);
                    }
                }).show();
    } catch (NameNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:com.amaze.filemanager.fragments.AppsList.java

public boolean unin(String pkg) {

    try {//from   w w w.j a va  2  s  .  c  om
        Intent intent = new Intent(Intent.ACTION_DELETE);
        intent.setData(Uri.parse("package:" + pkg));
        startActivity(intent);
    } catch (Exception e) {
        Toast.makeText(getActivity(), "" + e, Toast.LENGTH_SHORT).show();
        e.printStackTrace();
        return false;
    }
    return true;
}