[Q] How to return back to previous activity ? - C++ or Other Android Development Languages

I am new to Android development, hence kindly forgive any unintentional mistakes, if made.
I have a native activity rendering using ES2.0. The app needs to start twitter authentication (it uses twitter4j).
I am starting a new activity with twitter auth url. It shows the login page. I give userId, password, the native browser says now it would be redirected to the previous page or something. Then I see a black screen which apparently is the default browser still on top of the application. If I go to home, and background processes, I see my app and the browser as separate activities which makes sense.
Now my question is , how do I code my app to return back to the application once the authentication ends?
Here is the code flow to start the new activity
1. Native code calls JNI function to start authorization
2. The Java function creates an AsyncTask, in doInBackground() it gets the request token using getOAuthRequestToken(URL) where URL = custom url "app1://callback".
3. in onPostExecute() , app starts new intent activity using this code
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(requestToken.getAuthenticationURL()));
BaseGameActivity.startActivity(intent);
Log.debug("authenticate task post ends");

Related

[Q] how to prevent multiple service starts?

Hi All,
This threat should be posted into "Android Software Development" category but because I'm new here I can't do that.
I'm building an RSS feed aggregator application.
It has an UI where user can read the aggregated RSS items and it has a service that is running in the background to fetch RSS feed periodically.
The service must run even if the UI is closed.
The service started in START_STICKY mode by the UI activity's onCreate() overrided function, then the service register a timer.scheduleAtFixedRate() in it's onStart() overrided function for the scheduled job (feed receiving).
It is working fine, if I leave the UI then the service keeps running and the scheduled job is executed in right way but here comes my problem:
If I leave the UI with "back key" and not with the "home key" then next time I starting the app it's UI activity onStart() will run again, it will call startService() again and because of that a new timer.scheduleAtFixedRate() will execute and it will extend the scheduled jobs with a same one, so after that 2 scheduled jobs will run and every time this "UI restart" happens a new scheduled job will registered.
I saw lot of tutorials in this topic, but those are contains user interaction based service start/stop (for example start/stop service with button) with UI lifetime services and they don't handle this problem.
So my questions are:
- What is the right way to start these type of services?
- What is the right way to take care about scheduled job registering or how can I prevent this multiple job registration?
Thank you for your help!
Andrew
I made a workaround to fix the issue.
In my service class I defined a boolean variable what is basically false and it will change to true when the first scheduled task is registered and the task registration in the onStartCommand() function is only happens when the boolean variable is false.
In this way everything is working fine but I'm not sure that this is the right way to handle the problem...

[Q] SMS Intent Filter

I'm developing an SMS scheduler android application, and would like to include my app in the chooser when a user is trying to send an SMS outside of my app.
i.e. after using the voice commands to create a message, it asks which application you'd like to use to complete the task.
I'd like to add my app to the chooser for as many starting points as possible, including possibly the ability to intercept a message after you press send in the messaging app, and ask if you want to send it with my app.
I believe I should be using intent filters with particular mimetypes, but I dont know which ones. Is editing the manifest all I have to do?
EDIT: is this the correct thread?
So I've been working on sending information from another activity in the same app. I have a main menu activity with a listview containing pending messages and a compose activity which can accept strings, etc to load into the edittext fields. (This works)
Do I need this bundle to be in a particular SMS formatting (keys for Strings and such)?
No it belongs in android development.

[Q] WebView with user-defined URL and fading out address field

Hello!
I am new into Android developing. I got some experience with WebView, though. I already managed to create a fullscreen WebView with hard coded URL, some features, etc.
What I want to do now is the following:
1) first, the user should get an address field when the app starts where he/she is able to type an own URL
2) then this field should disappear
3) after that WebView is loaded as usual, but in fullscreen mode without status of the device, etc
I am able to do 3), no problem here. What I don't get is how WebView handles this address field: I already made an application with a static address field and a go button. But this address field is there all the time. If I could fade it out somehow after an user typed the address it would also help, I think.
Hope to hear from you soon!
All the best

Is the In-app browser gone from Facebook app?

I am a web developer, and my boss always ask me how to redirect Android mobile phone user to mobile version of the site,
and we both know basically check the user string to see if it contains 'Mobile', but the webview In-app browser in Facebook always return some non-standard user agent string, ex:HTC M7 will not contains 'Mobile', so is hard to determine it's mobile / tablet.
And today I try to check the user agent string again on my phone, the in-app browser is gone, I didn't turn of in app settings, it missing the setting too, also my wife's phone is gone.
Can anyone can let me know is your Facebook app also missing the in-app browser now?
Maybe Facebook removed the feature/
Thanks.

How to launch default activity for any given uri/url

I am a kodi addon developer and I believe I have skills more than average when it comes to Python. I am the sole maintainer of the AliveGR addon, the most popular greek addon around the world.
On Android I still suck... I am able to call an android activity from within Kodi with very specific intent, data uri and package name, but how can I call the default app for twitter, facebook or even a web browser?
Example:
Code:
control.execute('StartAndroidActivity("package_name","android.intent.action.VIEW","","url")')
Where package_name could be 'com.google.chrome' and url could be 'facebook.com'

Categories

Resources