Design and implementation of a specified app from a third-party launcher authorization launch

Source: Internet
Author: User

Case Background:

Case requires the first time a specified application is launched from a third-party Launcher , the popup dialog prompts the user for authorization to start, and if the user is not authorized, the next time the app is launched again, the dialog box prompts the user for authorization. Until the user has successfully authorized the app, it starts directly without authorization.

Then from the above description, we can be implemented in two steps, first launcher app framework layer to complete the specified app Configuration and analysis. So since case requires the launcher app when the user first boots or restores the factory settings. authorized to start.

Then the first boot and restore factory settings first launched the APP is the Boot wizard, so in order not to affect the overall performance of the system, we put the configuration of the specified APP in the Boot wizard to complete, Finally, the overall realization of the idea is to complete the right.

After the user first power on or factory reset, the Boot Wizard starts, read the specifiedAPPApply the package name and store information about the app package name to the database "Android.provider.settings.systemtable, use all of the application package names in the/"separate Save as a record, such as"nameto beCust_packagenames,valueto beCom.bill.test1/com.bill.test2/com.bill.test3". Launcheryou only need to callandroid.provider.Settings.System.getString (Context.getcontentresolver (), "cust_packagenames");You can obtain the required processingapkThe package name.

Users fromLauncherSpecified at startupAPPtime (such asCom.bill.test1),Launcherside can callandroid.provider.Settings.System.getInt (Context.getcontentresolver (), "Com.bill.test1", 0);to determine if the user is authorized, if the database does not have a correspondingKeyThe default value will be taken0If the user authorizes the app,Launcherside can callandroid.provider.Settings.System.getInt (Context.getcontentresolver (), "Com.bill.test1", 1);to deal with.

So how does the Boot wizard implement the app configuration and read the saved to the database? The following is the full source, interested readers can make reference.

Add code in Array.xml:

  <string-array name= "Cust_apps_packagenames" translatable= "false" ><item>com.bill.test1</item> <item>com.bill.test2</item><item>com.bill.test3</item>  </string-array>

Add code in Mainactivity.java:


    @Override public    void Onresume () {        super.onresume ();        XLOG.D (TAG, "Onresume");        string[] Packagenames = Getresources (). Getstringarray (        r.array.cust_apps_packagenames);        StringBuffer claro_packagenames = new StringBuffer ();        for (String packagename:packagenames) {            claro_packagenames.append (packagename);            Claro_packagenames.append ("/");        }        Android.provider.Settings.System.putString (Getcontentresolver (), "Cust_packagenames", Claro_ Packagenames.substring (0, Claro_packagenames.length ()-1));    }



Design and implementation of a specified app from a third-party launcher authorization launch

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.