I have three existing apps. Now i want to combine all the three into single app.
Say i have three button, when i click button 1 then app 1 should run. And when
button 2 is clicked app 2 should run. Is it possible in android studio? have
have tried searching but nothing helped.
From this SO start application knowing package name. Just use these two lines you can launch any installed application whose package name is known:
Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage("com.example.abc");
startActivity( LaunchIntent );
for the unknown package name
PackageManager pm;
pm = getPackageManager();
// get a list of installed apps.
packages = pm.getInstalledApplications(0);
I'm going to preface this by saying I do not have any experience with Android Studio. Hopefully it bears some resemblance with its terribly simplified counterpart App Inventor.
Anywho, I would create an independent main screen (activity?) that has 3 buttons on it and paste the three existing apps' code into other screens in the same app. Each button would open its corresponding screen/app through opening a new activity.
Got the solution. I just converted the three applications to library and imported them into the main app. Now i can call any activity from any of the three app any time as required. While using package manage all the three apps would have to be installed separately. Thank you coder and himty for sparing some time to answer my question. But still i have a problem. I am actually working on watch faces. Even though i can launch any activity, i still can't change the watch face. Tried Wallpaper but we can only open the face picker & cannot set the watch face.
ComponentName unique=new ComponentName(MainActivity.this,BlackOwlBlue.class);
Intent i=new Intent(WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER)
.putExtra(WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT,unique)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
Related
I am new in android and I have develop an application in android but the issue is when i install it on my device it shows me 2 icons one is working and other one says that receipt organizer has been stopped unexpectedly.Kindly let me know how i can get out of this rid ?Is it some kind of code error or problem in the manifest or properties ?Also one more question now my api level is set to 18 if i set it to previous version then the functionality will not get disturbed right ?So let me know if any one can help.
Look at your manifest file. Your manifest file should have only one activity that has the LAUNCHER in the intent filter.
Choose your main activity (which should have this intent filter), and delete the intent filters from the other activity. after that, you should see only one application icon.
I am trying to open a different, already installed android application within another, on click of a button. The new application should be opened in a part of the screen within the calling application.
Currently, my code creates a new intent and runs the called application in that. the calling application disappears. Here's my code:
b.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
PackageManager pm = getPackageManager();
Intent intent = pm.getLaunchIntentForPackage("com.ritwik.camera");
startActivity(intent);
}
});
Ideally, it should open as a part of the same screen, without sidelining the parent(calling) application. How do I do that?
When you start an Intent to execute another application (i.e. because you are implementing a launcher or a main menu replacement) you are actually asking android to execute the application identified with a specific package (or the one satisfying some specific constraints, like the ability to handle images, videos, etc), without any clue or reference about the Activities it contains (nor the ability to get any...).
Therefore I don't think that what you are trying to achieve is possible with the current version of the OS (unless some vendor is providing extensions to do just that, see the comment by Pratik).
The new application should be opened in a part of the screen within the calling application.
This is not possible with conventional third-party application UIs.
AFAIK, the split-screen feature (Adaptive UI) is supported from Android 3.0 onwards.
That has nothing to do with embedding the UI of third-party apps into your own.
So I didn't get what you meant to say by "it's not possible with the current version of the OS"
It is not available on any stock version of Android released up through March 26, 2013 at 9:50am Eastern Time.
Certain device manufacturers, like Samsung, have extended Android with multi-window capabilities. However, the control over those windows lies with the user and the (modified) OS. Unless there is something in their S-Pen SDK for this, you have no way of starting another window.
Android also has RemoteViews, which is a means of passing a simplified UI between processes. Using this, it is possible for one app to embed RemoteViews published by another app. You see this with app widgets on the home screen, for example. However, both apps have to be written with this in mind, such as an app publishing an AppWidgetProvider to supply app widgets to home screens.
As far as I know, this is NOT possible. You can only launch the new activity, but you have no control of it.
EDIT: Some devices offer this possibility using Cornerstone or similar frameworks, but I haven't seen an option for developers to use this for their own apps.
I'm new to android. I've developed a library and integrated the same with two apps. And I have broadcast receiver for screen unlock in that library.and have stored unlock count in sharedpreferences. If the count is 2 then i ll show popup.and each application will be having its own private sharedpreferences. Whenever I receive unlock broadcast and the count is 2 then i'll show a pop up message.here, Since I have integrated the lib with two app,two popup msgs are coming up.I just want to show only one popup from any one of the app.I couldn't find a solution for this.How it can be achieved. any idea pls?
Thanks
Jeyanthi
You can list the installed applications on the current device using the Package Manager, like this :
PackageManager pm = getPackageManager();
pm.getInstalledPackages(0);
Then each PackageInfo contains the package name (com.yourname.package1, com.yourname.package2). You will also have the install and last update time (see the PackageInfo reference).
Then you could on each of those app detect if another one exist and then have some kind of priority. For example, only the last installed app display a popup, or use a priority of your own (application A before application B).
Platform: ASUS Nexus 7, running JellyBean
I've created a kiosk application by making it the default HOME / LAUNCHER intent. I need to be able to get out of it, to the stock android launcher, via a secret code for service and maintenance.
I've searched all over, and can't find a good, succinct answer. The best I've come up with is to create an intent chooser (Intent.createChooser(Intent i, String title)) and choose between my launcher and the stock launcher. This is okay, but really a workaround.
I've tried:
PackageManager pm = this.getPackageManager();
try {
Intent i = pm.getLaunchIntentForPackage("com.android.launcher");
if (i != null)
this.startActivity(i);
}
catch (ActivityNotFoundException e) { }
and I get null for the intent every time. Yet, the stock launcher shows a package of "com.android.launcher" on my tablet. Clearly I'm getting something totally wrong here.
Step #1: Document that they need to run your app manually once out of the launcher before setting it up as the home screen.
Step #2: On that first run, use resolveActivity() to find out what the default home screen is, and hold onto the relevant pieces of information from the ResovleInfo (e.g., the component name) in some persistent data store.
Step #3: Use that data to bring up the default home screen as needed from whatever back door you have in your kiosk app.
I'm trying to write a launcher-like application (I'm not planning to release it, it's just for me to use) but I don't seem to find any way to launch the Market.
All of the answers I've found actually perform a search on the Market (using a uri "market://") or even worse they run the Market on a specific app page, while I'm trying to show the main page of the Market, i.e. the page shown when you run it from the launcher.
I tried using just "market://" as a Uri, without query strings, but it doesn't work; I also tried to get exactly the same "signature" of the "start activity command" that appears in the LogCat when I run the Market from the Launcher (by manually editing component, flags and categories), but it still doesn't work.
Is there any way to get it to show the main page?
Thanks in anticipation.
Intent intent = new Intent();
intent.setClassName("com.android.vending", "com.android.vending.AssetBrowserActivity");
startActivity(intent);