How To Open An Application Inside Another Application Within The Latters Boundaries In Android?
Solution 1:
You basically can't. It goes against the rules of Android. The most you can do is open a web page as part of an app. This is done using the webView. You can control the boundaries of the screen by setting the bounds of the webview in the xml file for the Webview.
publicclassWebViewFragmentextendsFragment {
publicstaticfinalStringARG_SECTION_NUMBER="section_number";
publicWebViewFragment() {
}
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
ViewmainView= inflater.inflate(R.layout.fragment_facebook,
container, false);
WebViewwebView= (WebView) mainView.findViewById(R.id.webView1);
webView.setWebViewClient(newMyWebViewClient());
webView.getSettings().setSupportZoom(false);
webView.getSettings()
.setJavaScriptCanOpenWindowsAutomatically(true);
webView.getSettings().setAllowFileAccess(true);
webView.getSettings().setDomStorageEnabled(true);
webView.loadUrl(""); //URL needs to be entered in this linereturn mainView;
}
}
Hope this helps :)
Solution 2:
This is not possible because of security reasons. Previous versions of Android allowed this with System-grade permissions (ones that most developers will never get to use), but it was rarely used and is not in the SDK anymore as far as I know.
Some manufacturers implement additional functionalities like Samsung's Mini Apps (if I remember the name correctly) which may be opened in a floating window above other apps. You can also draw your own app over another using a service (like Facebook messenger does). But there is no way to force a third party app to do any of these things.
However, every time you open an application from your application, the process of the new one will have the invoker's process assigned as parent. This allows you, to some extend, check if this other app was opened from your app.
Also, your app will not die when opening a new one, but will simply be "below it". If you need some kind of data from the other app, you may start it forResult
. This way the other app will "know" you are expecting a defined result from it, so it will process some data and pass it back to your app (which will reappear after the other one is finished preparing the result).
Solution 3:
It could be possible if use the android property
android:launchMode="singleTask
while declaring your activity in the AndroidManifest.xml (inside the activity element).
If you so so, if you minimize your app and launch it again (from background or from app icon from the list of apps), it would still show you the new app.
I am not sure if the result would be as per your desired effect.
Post a Comment for "How To Open An Application Inside Another Application Within The Latters Boundaries In Android?"