How to Install the App Twice Without Interference in Android

How to Install the app twice without interference in android?

Well it worked on other device with more recent platform ! Anyway the proper response will be you just have to change the name and the package of the application.

EDIT 1: Now if you are using Android Studio use applicationIdSuffix to have one app for each flavor.

debug {
applicationIdSuffix ".debug"
}

Read more here developer.android.com

Android – multiple custom versions of the same app

Perhaps the built-in Android "library" concept was not fully baked at the time of the original post, but it may be the preferred method as of 2011. Follow these steps for an ant build:

Starting from a working app (let's call it directory "myOrigApp", package com.foo.myapp), just add this line to "default.properties" to make it a library:

android.library=true

Now create a new app in a sibling directory in any way you prefer (let's call it directory "sibling", package com.foo.myVariant). Using Intellij Idea, for example, create a project 'from scratch' with directory 'sibling' and it will create all the files/directories you would normally need.

In that new, sibling directory edit "default.properties" to add the dependency:

android.library.reference.1=../myOrigApp

Copy over the Manifest from the original dir:

cd sibling
cp ../myOrigApp/AndroidManifest.xml ../myOrigApp/local.properties ../myOrigApp/build.properties .

Edit that copied Manifest file to change its package name to your new variant, "com.foo.myVarient"; that's the only change.

If you just run the ant build scripts, you may be done. (I had to just set up signing keys.)

If you want to set up an IDE like Idea to have the library project as a dependent of the variant project, follow these steps to add a library project to the variant project (assumes you already have a project set up for both):

  • Open the original project, bring up Project Settings, select your Facet and check "Is Library Project" and save.
  • Open the variant project, bring up Project Settings, select Modules
  • Add a module
  • Select “Import existing module”
  • Browse to the Original directory (myOrigApp) and select its .iml file (IntelliJ project source file)
  • Click "Finish." (The library project is added as a module within the variant project.)
  • In the modules list click over the Variant project to select it.
  • On the right hand side select the "Dependencies" tab.
  • Click "Add…"
  • Choose "Module dependency…" (A list should appear that includes the name of the module/library you previously added to the project--perhaps the only entry in the list).
  • Select the library project you added and press OK. (It will be added to the list of dependencies of your project.)
  • Press OK to finish configuring the project. (You should see 2 modules, with the library's resources and classes available and recognized in the Variant project.)

How to install various applications derived from base app

I have changed the name of the base folder, and in AndroindManifest.xml I changed the package of the app, but if I install the client app it overwrites the BaseApp.

Don't do that.

A client buys our app, so I have to change some minor things (colors, titles, background and icons pngs, that sort of things).

Have one project for the app. Have one product flavor per customer, plus probably a "generic" one that you use for testing.

Is there any way I can install the base app AND the client app in the same phone?

In your product flavors, use applicationIdSuffix to put a per-client suffix on the application IDs. The application ID is what makes an app unique; having unique suffixes means that each of your client's apps is unique. You need this for the Play Store or other distribution.

Android studio default project fails: Error:Failed to resolve: com.android.support:support-v4:25.2.0

Try this:

  1. in Android Studio, open Tools -> Android -> SDK Manager
  2. under tab "SDK Tools" un-check the libraries causing problems
  3. click "apply" to uninstall them
  4. re-check the same libraries click "apply" to reinstall them
  5. close SDK Manager and run Gradle sync / build

android compass seems unreliable

Well after much testing, and debugging. I came to the conclusion that yes as some of you mentioned the differences my droid 1 and Nexus S were purely hardware difference and magnetic interference.

However the Droid X was a different issue, whatever i tried i could not get the correct readings out of the recommended way with getRotationMatrix and getOrientation, even when added re-map coordinates function. So after some tinkering with no success i figured id give the Orientation sensor way a shot.

Google says that this way is deprecated and they recommend doing it the way i started off with, however i tried all types of combinations with that way with no success. So I went ahead and ignored thier warning and used the orientation sensor ... and it worked. Why ? i have no clue, the droid x is newer os than my droid 1 so it shouldn't have to do with using legacy code. However it does make sense why compass apps wrote to target 1.6 would work while my app doing the "recommended way" was not working.

If anyone has any better way to do this let me know, or if you know a way to make it work with getRotationMatrix and getOrientation also do tell.

Otherwise for anyone else who hits this brick wall as hard as I did heres the code that ended up working for me.

my on sensor changed

        switch (event.sensor.getType())
{
case Sensor.TYPE_ORIENTATION:
m_vforientVals = event.values.clone();
break;
}

if(m_vforientVals != null)
{
m_fCompBearing = m_vforientVals[0];


mCompHead.setText("" + (int)m_fCompBearing);

calcOffset();
rotateCmp();
}

and initialize the sensor listener

    mSMngr.registerListener(mSListener,mSMngr.getDefaultSensor(Sensor.TYPE_ORIENTATION),
SensorManager.SENSOR_DELAY_NORMAL);

Need help to understand memory leak in my Android app

MY FINAL SOLUTION

I found a solution on my own now. It runs stable and doesn't produce memory leaks when I start and stop the application a lot of times. Another advantage with this solution is that I was able to kick out all this ProcessNotification.isCancelled() parts.

The key is to hold a reference to my InitializationTask in my ApplicationContext. With this approach I can resume the running AsyncTask in a new MainActivity when I start a new one. This means that I never start more than one AsyncTask but I attach every new MainActivity instance to the currently running task. The old Activity will be detached. This looks like this:

new methods in ApplicationContext:

public static void register(InitializationTask initializationTask) {
ApplicationContext.initializationTask = initializationTask;
}

public static void unregisterInitializationTask() {
initializationTask = null;
}

public static InitializationTask getInitializationTask() {
return initializationTask;
}

MainActivity

(I have to put the progressDialog in here, otherwise it wouldn't be shown if I stop and start a new Activity):

@Override
protected void onStart() {
super.onStart();

progressDialog = new ProgressDialog(this);
progressDialog.setMessage("Processing.\nPlease wait...");
progressDialog.setIndeterminate(true); // means that the "loading amount" is not measured.
progressDialog.setCancelable(true);
progressDialog.show();

if (ApplicationContext.getInitializationTask() == null) {
initializationTask = new InitializationTask();
initializationTask.attach(this);

ApplicationContext.register(initializationTask);

initializationTask.execute((Void[]) null);
}
else {
initializationTask = ApplicationContext.getInitializationTask();

initializationTask.attach(this);
}
}

MainActivity's "onPause" contains initializationTask.detach(); and progressDialog.dismiss();. finalizeSetup(); dismisses the dialog too.

InitializationTask contains two more methods:

public void attach(MainActivity mainActivity) {
this.mainActivity = mainActivity;
}

public void detach() {
mainActivity = null;
}

onPostExecute of the task invokes ApplicationContext.unregisterInitializationTask();.



Related Topics



Leave a reply



Submit