You can use "start adb shell am start" with the arguments you will need to look for to start a new package.
If you are worried not to confuse the obsolete, adb delete the old file before installing the new one or better yet show how you show your version of the spray display.
In fact, you can use the beginning to trigger an action that is unknown to trigger, so you can use it to directly trigger an “activity” that will display the current version. It’s your choice if you make it available in the normal way of the application or use it only once as a splash.
You should also be able to analyze the output of the adb installation command - you will need to see if it sends errors / success to stderr or stdout.
UPDATE: Here's how to do an operation that you can use to turn on the screen and display a message, for example:
adb shell 'am start -n com.example.testreport/.ReportActivity -e result PASS'
The code is heavily cut from the built-in AlarmClock of an earlier version of Android, this will require:
<uses-permission android:name="android.permission.WAKE_LOCK"/>
in manifest
package com.example.testreport; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.os.PowerManager; import android.util.Log; import android.view.Gravity; import android.view.WindowManager; import android.view.WindowManager.LayoutParams; import android.widget.TextView; public class ReportActivity extends Activity { PowerManager.WakeLock sScreenWakeLock; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(android.view.Window.FEATURE_NO_TITLE); getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); } protected void onStart() { super.onStart(); if (sScreenWakeLock == null) { PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); sScreenWakeLock = pm.newWakeLock( PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, "ReportActivity Wakelock"); sScreenWakeLock.acquire(); } TextView tv=new TextView(this); tv.setTextSize(30); tv.setGravity(Gravity.CENTER); Intent i = getIntent(); if ((i != null) && (i.hasExtra("result"))) tv.setText(i.getStringExtra("result")); else tv.setText("???"); setContentView(tv); } protected void onStop() { if (sScreenWakeLock != null) { sScreenWakeLock.release(); sScreenWakeLock = null; } super.onStop(); } }
He probably can use some refinement and improvement; for example, at the moment you cannot turn off the phone with the power button, unless you stop the action by moving to lose visibility.
source share