Open activity as pop-up and not in other screen in Android? - android

I am working with Bluetooth Chat sample code. In sample app the Device opens up in another screen but I have implemented the same code with the difference that DeviceListActivity is called as soon as the app is started but this opens it in another screen and I want that it should be opened as pop-up in Bluetooth chat sample code.
Can someone let me know how to open Activity as pop-up?

in your manifest file, set your activity theme to dialog
<activity android:theme="#android:style/Theme.Dialog">

Related

Clicking on an ad opens a browser, but I cannot go back to the launching activity screen of my Android app

Even though there is a similar case here:
After click AdMob ads, I cannot return to my Android app by back button
the code proposed didn't solve my case. So I am posting this if there's somebody with fresh ideas to solve this.
I have coded an app for Android. Now I am trying to add ads to this app.
I am implementing the ads from Appodeal. When I show an ad type called MREC (which is a square-like banner) on my main activity, if I click
on the ad, it will open a tab in the default browser of the device.
The problem arises when I press the square button on the device (the menu that displays the current running apps): it displays the browser and
also my own app as active. If I select my app, Android wont let my app come to the forefront, instead it shows the device background or the
recently opened browser. It's like the browser has taken over the "identity" of my app.
So, why I cannot return to the activity screen where the ad is located, and from where the click launched a browser tab?
One more thing is that in the sample apps that Appodeal provide, there is no code in onResume, and there isn't any different code from the
Appodeal SDK in the manifest, and yet, the app returns correctly to the main activity after coming from the browser tab. I am also trying to implement Admob ads, and the same effect happens as described in this post.
Solved! I implemented the advice by the User: AngraX from this page:
How can I do that in Android. Activity -> WebBrowser -> Acrivity, but Press Back not see the WebBrowser
where he recommends to add this to the Main Activity declaration in the Manifest file of your App:
android:allowTaskReparenting="true"
android:launchMode="singleTask"
And it works! After the Smaato ad in my App launches a tab in the default web browser of the device, I am now able to return to my Main Activity, no matter if the returning is done in any of these 3 ways:
By pressing back button the necessary number of times to return to the Main Activity screen, no matter if you press back button from your App or from the browser
By clicking the close (X) button on the screen of your App
By pressing the square button of your Android device (Menu Button), and then choosing your App

Android Open Activity Multiple Times from Notification

When clicking my notification, it opens the activity once and works fine, but then the notification remains in the message tray and doesn't open anything again.
Is there a way to set up the notification to open the activity every time the user clicks on it? Or is this not feasible with Android?
Thanks!
try to put launch mode to activity which you are trying to open from notification.Link will provide description about launch mode
<activity
android:name=".SingleTaskActivity"
android:label="singleTask launchMode"
android:launchMode="singleTask">
Helpful link for Launch mode

Android pop up dialog from service

What is the way to create a popup screen that's opened from a background service while app is not running in foreground?
Refer to the Skype answer-reject dialog when there's an incoming call:
I have a background service that always runs even the app is not visible to user, but how can I pop up a screen like in the image from that service?
Update:
I am looking for the term used for this kind of screens, is it a regular activity started from the service, or some form of "notification" ?
This popup shows exactly that.
You can start an Activity with:
android:theme="#android:style/Theme.Dialog"
Do Read: If I can remember properly, I have read somehwere that it is against the Android guidline of using popup from a service. It recommends using a Notification service.

How to restart my application in Android?

I am developing an application in that I want to open url(www.google.com) with android default browser(com.android.browser). After some time I want to close or hide the browser and show my application to the user. I tried the following
Broadcast Receiver
Timer
Handler
None of them is working.
FYI -- I am starting the browser from fragment. I want to show the same fragment after closing or hiding the browser. The broadcast receiver is working but it is opening the initial fragment but I want the same fragment when I start the browser.
Please any one help me

Start same android last activity on relaunch after closing the app

I am developing an app that is having function to upload images to instagram. So when i upload the image to instagram and press the home button,the app is closed and when i ma relaunching the app it is starting from the main[ splash screen] activity.
In that application i am having option to take images from gallery and the camera. So when i press the home button and relaunch the app it should start the activity where i can chose the images.
I have tried a lot. If anyone have the solution please help me out.
By default last activity will open when relaunch the app.But some device it will not happen.
I don't know the proper reason but may there is settings problem in that device.
By default the last activity will be shown when the app is restarted. Unless you have added any 'no history flag' or:
android:noHistory="true"
Set noHistory to false. ..

Categories

Resources