Is it possible to install an application via adb b

2019-05-04 10:38发布

问题:

My company is distributing both the hardware (samsung galaxy tab 10.1) and the software (my application) to our customers.

My intent is to "skip" the google account linking and use adb to install my production-signed application directly onto the tablet (identical as the apk I upload to google market). This will allow me to pre-configure the tablets for our customers, change the screen background to our logo, etc.

However, once the tablet has been delivered to the customer, I would want them to attach a google account to the tablet, and still be able to get updates from my application via the marketplace. In my testing, the application I manually installed never shows up in the list of applications in google market.

Is this possible?

Tim

UPDATE: I ended up writing a "Launcher" application which I will manually install on the device. It has one activity with the theme:

android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"

the activity has this code:

public class LauncherActivity extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //setContentView(R.layout.main);
    startApplication("applicationnamehere");
    finish(); // this kills the activity immediately.
}

public void startApplication(String application_name){

    boolean successfulLaunch = false;
    try{
        Intent intent = new Intent("android.intent.action.MAIN");
        intent.addCategory("android.intent.category.LAUNCHER");

        intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
        List<ResolveInfo> resolveinfo_list = getPackageManager().queryIntentActivities(intent, 0);

        for(ResolveInfo info:resolveinfo_list){
            if(info.activityInfo.packageName.equalsIgnoreCase(application_name)){


                Intent launch_intent = new Intent("android.intent.action.MAIN");
                launch_intent.addCategory("android.intent.category.LAUNCHER");
                launch_intent.setComponent(new ComponentName(info.activityInfo.packageName, info.activityInfo.name));
                launch_intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(launch_intent);
                successfulLaunch = true;
                break;
            }
        }
    }
    catch (ActivityNotFoundException e) {
        launchMarket();

    }

    if (!successfulLaunch)
        launchMarket();
}

private void launchMarket() {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(Uri.parse("market://details?id=packagenamegoeshere"));
    startActivity(intent);
}

}

You can stuff the constants into strings.xml.

It works well with the only issue being that it hangs around on the home screen even after my main application has been installed by the user. Since it (by default) tries to launch the LAUNCHER for my application, its not the end of the world.

回答1:

It should be possible - look into what Titanium Backup does. It has a Market Doctor feature that can re-establish links to the Android Market after you restore the apks and data files using Titanium Backup.

You could also try loading a factory image onto some phone or tablet, skipping the account creation process, and seeing what the market database looks like for the included apps such as Youtube, Facebook, Gmail, Maps, etc.



回答2:

In my testing, the application I manually installed never shows up in the list of applications in google market

This is because you didn't publish your app in Android market.

Is this possible?

As long as you use the same package name, maintain version increment properly in AndroidManifest.xml and signed with same keystore. where and how do get the latest apk doesn't matter, it will trigger the upgrade.

Checkout the Signing Strategies - Application upgrade from official dev guide.



回答3:

I have found that I will get application updates after installing through adb if the following criteria are met: 1. same package name 2. version code specified in AndroidManifest.xml adb version < version code play store version 3. same key used to sign both apk's



回答4:

It is possible. Proof: most of the phones is supplied with YouTube, Twitter, Facebook and other applications and these applications is possible to update via Market.