How do I start my own work instead of the mobile home screen as soon as the download finishes with android?

After the download is complete, I want to load my own activity as the first screen instead of the mobile home screen. Meanwhile, there is a delay, so how to solve it ... thanks in advance.

+3


source to share


2 answers


check this out: OtaStartupReceiver

this class is the source of the phone apk in android source please check the method private boolean shouldPostpone(Context context)

On devices that provide a phone initialization wizard (such as the Google Setup Wizard), we allow you to defer the OMA CDMA setup so that it can be done in a single wizard. The master is responsible for

(1) shutting itself off after starting it up and / or

(2) setting the 'device_provisioned' flag to something nonzero and

(3) call OTA Setup with the action below. NB: Typical phone initialization wizards will set themselves as the home screen (category "android.intent.category.HOME") with a priority higher than the default. The wizard should set "device_provisioned", when it exits, disables itself using PackageManager.setComponentEnabledSetting (), and then start the screen.



as shown above:

you can create an activity in AndroidManifest.xml

    <activity
        android:name=".Demo"
        android:label="@string/app_name"
        android:screenOrientation="portrait" >
        <!--android:priority added-->
        <!--category.HOME and DEVICE_INITIALIZATION_WIZARD must have-->
        <intent-filter android:priority="1000">
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.HOME"/>
            <action android:name="android.intent.action.DEVICE_INITIALIZATION_WIZARD"/>
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

      

+5


source


I advise you to be careful when doing this!

Before starting, I think it is a good idea to enable USB debugging, so if anything happens you can fix it with ADB.

I was working on a project where a client wanted the app to appear without showing the default Android home.

For this, I advise you to do it with care. System I used: Root Android 4.0.3

In your manifest add this inside your activity:

<activity android:name=".MainActivity" android:label="@string/app_name">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />  
        <category android:name="android.intent.category.HOME"/>  <!-- this will make your app work like a launcher -->
        <category android:name="android.intent.category.DEFAULT" />                
    </intent-filter>
</activity>

      

For this to work, you can look in Settings / Applications / All

Find a "launcher", click on it and press the button Clear Defaults

.



After that press "HOME" button, Android will ask you which application you want to run, if you select your application and check the "make as default" checkbox, it will always work as your home screen, making your application a launcher. So when you restart your device, it will always display your app.

Beware! ... If you do this, you may lose access to your home screen and not be able to access your settings again. So you either need to access it via ADB or build and "run" like I did.

In my app, in the admin area, I added a button that calls the following:

public void custom_launcher(View v){
    startActivity(new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER));
}

      

This will bring up the Android menu from which you can go back to the settings menu. In the settings menu, you do the same as in the launcher if you want to use the default Android launcher again.

To do this, go to Settings / Applications / <app-name>

, then click "Clear defaults". When you hit home again, Android will ask you which launcher you want to use, Android Launcher, or your app.

+1


source







All Articles