How to restart my application in Android? - 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

Related

Can we get opening and closing time of other apps in our app?

In android, Can we get other apps opening and closing time in our app?.
our app should run continuously in background to get other apps time.
Broadcast Receiver
You cannot track the opening and closing time of other app.
If you have created own other application then you can track the closing and opening time of Application A inside Application B. If you want to achieve this feature the you need to use receiver with own event.

How to stop/pause an activity in watch from mobile?

I am currently starting an activity in watch from mobile by clicking a button. I am using wearable listener service to do it. Once the activity is started, the user performs gestures which are recognized and sent to mobile. So at some point in time, I want the user to click a button in mobile to close/pause this activity in watch. How can I do it? Should I destroy it or pause it? What should be my approach? Please advise
When you receive the message telling to close app in watch from phone,you can cancel all running work and close all activities in watch app or call System.exit(0).

android hidden app strategy

I'm trying to create an app "hidden" from applications list.
The way i though the user will start the app is through a Receiver listening for NEW_OUTGOING_CALL and intercept a particular number dialed.
The problem is that on new Android versions, this receiver will never be activated if the app never start once. (Starting the application from a BroadCastReceiver (NEW_OUTGOING_CALL doesn't always work)).
I can't figure out a workaround for this problem: the app launcher is totally hidden so the user cannot never launch the app, and the receiver would never be activated if the app will never start.
Is there any other strategy or workaround for hide and launch the app with some kind of secret action?
Create a activity with manifest file pointing it as the the Launcher activity and make it transparent and call its finish method in onCreate. User clicking on that icon will have no idea that the activity is opened. But why don't you show the About application kind of screen in the launcher activity?

run the activity while it's not visible

I'm working now in a project to download images from the web and then show it after completing its download.
i made an activity class that has a button and text field and when the user press on the button, i started a service which will show a notification in status bar and after download i will show a message .
my main problem now is i want to go to other application or home page while the download is working.
i tried it but i after the download i got the message ,,, " Force quit"
should i use broadcast receiver or remote server to handle what i want.
Thanks,
The service should be the one downloading the content. If you go to the home activity our activity calls onPause, stoping all the work in progress.
Activities are just that, activities, they only work when visible and are built strictly for user interaction or a user activity, so this is impossible. Use a service instead. Here is a diagram showing lifespan of an activity:
Link to App activity explanation on Android developer site
You may need to call Looper.Loop() in your service to keep it running if you have any listeners in your service.

How to Resume Previous running application from An Application in Android?

Give me a little guidance:
as My Application is running with Broadcast Receiver and when ever my application in Background and any incoming event comes it triggers the my Application.
Now we want as We are listening or playing some video file or browsing on Android Phone
and with incoming event occur and my application launch(already running in Background),
If i will ignore the event , we want to go back previous running task (Like browsing, playing
video file application), How we can achieve?
Now I am using The store the running application package and Activity info before triggering the Event , and after finishing using this info we resuming the Activity and
It working fine but Only with Gallery Application Playing of Vedio file is not fine , It Crashes the Application and relaunch the Gallery App.
Please give me some Valuable points to make it up?
On calling finish, Previous application resume(Playing of Media file) but when next time
on getting broadcast intent and try to launch the Activity , The Activity is not launching
and application itself crashing.
After a long back I got solution of my problem and we need only use to this api
moveTaskToBack(true);
and automatically resumes the previous running task(like browser, media application or any thing)
Have you tried to start you activity by
startActivityForResult(Intent intent)
When you call finish() in the Activity you should return the the previous one, I am not sure if this will function over between Activity running in different applications. Give it a try :D

Categories

Resources