How to Automatically Run an App After Installation

From wizarPOS

Configure from TMS

Click Applications>Application, when add an application, click Advance, there is an auto run configure, now the label name is App Restart Entry.

The input format is type:component name

type: activity, service, broadcast

for example: activity:com.smartpos.autoremoveapk.MainActivity

Configure in AndroidManifest of the APP

metadata

Add any of the following meta-data extension element data in the <application> field of AndroidManifest to complete the declaration.

  • <meta-data android:name="cloudpos_activity_auto_start" android:value="XX.XX.XX.XXXX" />
  • <meta-data android:name="cloudpos_service_auto_start" android:value="XX.XX.XX.XXXX" />
  • <meta-data android:name="cloudpos_receiver_auto_start" android:value="XX.XX.XX.XXXX" />

meta-data data description:

Two parts of data contained in meta-data, the first part is to specify the type of component to be started, currently only three types are supported(cloudpos_activity_auto_start, cloudpos_service_auto_start, cloudpos_receiver_auto_start);

The second part is the class name of the absolute path of the component to be started, and the class name of the relative path is supported.

action

Add an action to the component that needs to be auto-started.

<action android:name="android.intent.action.AUTO_START" />

Example of AndroidManifest

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android"

   package="com.wizarpos.pinpadui.test">
   <application
       android:allowBackup="true"
       android:icon="@mipmap/ic_launcher"
       android:label="@string/app_name"
       android:theme="@style/AppTheme">
       <meta-data android:name="cloudpos_activity_auto_start" android:value="com.wizarpos.pinpadui.test.MainActivity" />
       <activity android:name=".MainActivity">
           <intent-filter>
               <action android:name="android.intent.action.MAIN" />
               <action android:name="android.intent.action.AUTO_START" />
               <category android:name="android.intent.category.LAUNCHER" />
           </intent-filter>
       </activity>
       <receiver android:name=".XXXXReceiver">
           <intent-filter>
               <action android:name="android.intent.action.AUTO_START" />
           </intent-filter>
       </receiver>
       <service android:name=".XXXXService" android:enabled="true">
           <intent-filter>
               <action android:name="android.intent.action.AUTO_START" />
           </intent-filter>
       </service>
   </application>

</manifest>