3

Hey i want when user is trying to un-install an app ,there comes password to unlock. Im following this code :

android: require password when uninstall app

but there comes an error in manifest "android:description="@string/descript"" Kindly help me.im badly stuck in it.there's no answer availble on google too

Community
  • 1
  • 1
Zaa Ra
  • 67
  • 2
  • 10
  • This is potentially the _worst_ idea I've ever heard. It may be that you have a good reason for it but, if I couldn't get rid of some crapware because it required a password, I seriously consider tracking down the author for some "re-education" as to who actually _owns_ my device :-) – paxdiablo Apr 02 '15 at 06:33
  • 1
    its a parental app like if child want to unistall an app,he cant and need his parent to unlock this – Zaa Ra Apr 02 '15 at 06:38
  • 1
    As per my comment on another question: examine the device every so often. If the app is gone, the kid loses it for a day. Next time a week. Then a month. They'll soon learn not to mess around with the oldies :-) – paxdiablo Apr 02 '15 at 06:43
  • lol yeah u r right but i have to do this task cause its my job task :( – Zaa Ra Apr 02 '15 at 06:53
  • No, that's okay, if it's your job, it's your job. Wish I could help you out further, best of luck. – paxdiablo Apr 02 '15 at 06:57
  • can you please recommend or refer someone to whom i take help regarding this ? – Zaa Ra Apr 02 '15 at 07:03

2 Answers2

0
    try the following code in your service 
    public static final String UNINSTALLER ="com.android.packageinstaller.UninstallerActivity";
private ActivityManager activityManager = null;
private ExecutorService executorService;


@Override
public void onCreate() {
    super.onCreate();

    executorService = Executors.newSingleThreadExecutor();

    activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
    LockerThread thread = new LockerThread();
    executorService.submit(thread);
}

   private void protactApp(String packname) {
            Intent pwdIntent = null;
            pwdIntent = new Intent("uninstaller.receiver");
            sendBroadcast(pwdIntent);


        }
class LockerThread implements Runnable {

    private String lastname;

    public LockerThread() {

    }

    @Override
    public void run() {

            ComponentName act = activityManager.getRunningTasks(1).get(0).topActivity;
            String packname = act.getPackageName();



            if (act.getClassName().equals(UNINSTALLER)) {
                Log.d("Tag", "package to be uninstalled");
                protactApp(UNINSTALLER);
            }
        }

and from receiver you can get action while uninstall the app so whatever screen you prepare for password or pattern that you can start before uninstall like applock application

Ajay Pandya
  • 2,417
  • 4
  • 29
  • 65
  • what is uninstaller.receiver? a class or build in something? – Zaa Ra Apr 09 '15 at 06:51
  • 1
    that is your custom broad cast same like we get action by intent filter this is custom broadcast – Ajay Pandya Apr 09 '15 at 06:55
  • how we get action in receiver? – Zaa Ra Apr 10 '15 at 05:46
  • there is no need to define action filter in manifest you will get action in your receiver @Override public void onReceive(Context context, Intent intent) { // TODO Auto-generated method stub String[] packageNames = intent.getStringArrayExtra("android.intent.extra.PACKAGES"); Log.d("Tag", "onReceive of uninstall intent"); } – Ajay Pandya Apr 10 '15 at 05:49
  • what is the code i write in onRecieve of broadcast receiver? – Zaa Ra Apr 10 '15 at 05:52
  • @Override public void onReceive(Context context, Intent intent) { c=context; Toast.makeText(c,"ON Received",Toast.LENGTH_LONG).show(); if (intent.getAction().equals("android.intent.action.PACKAGE_REMOVED")) { Toast.makeText(context, " onReceive !!!!." + "PACKAGE_REMOVED", Toast.LENGTH_LONG).show(); } } – Zaa Ra Apr 10 '15 at 05:53
  • there you can write the code for start lock service which will open the lock screen – Ajay Pandya Apr 10 '15 at 05:55
  • and yeah one another thing to remember is always create a REBOOT receiver so when your phone is shutting down and start than your service will again started – Ajay Pandya Apr 10 '15 at 05:56
  • when i cicked on unistall button , log is not showing – Zaa Ra Apr 10 '15 at 06:13
  • have you register receiver ? – Ajay Pandya Apr 10 '15 at 06:16
0

it would not help on 4.3 or higher but I am posting a link where you can find the solution and reason of why you can not do it. Here is the link. Hope it would help you in understanding the real milestone in this context.

Community
  • 1
  • 1
ghost talker
  • 402
  • 5
  • 15