Writing tests for an Android app that logs into Facebook - android

My Android app uses FacebookSDK for login. It's the first screen, and you can't do anything unless you login.
I want to write some Espresso tests to be ran on Greenhouse Continuous integration server.
I searched and I found FBSDKTestUsersManager on iOS, but nothing similar on Android.
What I plan to do is create a flavor of test and when that flavor is selected instead of a normal Facebook login button, I'd display a button that gets a test access token for the user, then brings them to the homepage of the app. However, I can't do that cause FBSDKTestUsersManager doesn't exist on Android.
Any suggestions?

The solution is to involve UIAutomator in your tests together with Espresso for Android. It will be possible to go outside of your app under test context and perform some actions on Facebook login dialog. Similar question here and the example in my blog post.

Related

Android launch application with custom credentials

I try to explain what I mean: as asked and replyied here you can launch an application from your own.
The problem is the following: I don't need only to run an application from mine, but I also need to run it with different credentials from the same application installed in my phone, so I need to run it with a different account.
For example:
With my application I want to run Facebook. Fine, I run my code by starting an intent with fb package name.
My problem is that I don't want to run facebook and find myself logged with my profile(the one logged in my phone) but I want facebook to be run as if it was a new and clear installation (it must prompt me for login with my credentials) and this must not remove my credential from my application in my home screen.
It's like creating another user on your phone and using an app on both users. The difference is that I want to do it with my app instead of with another user.
Probably my explaination is not perfect, I tried my best but it's hard to explain what I'm looking for. I know it is possible because this application does it, but I can't figure out how.
Thanks all for the help!

How can I customize Facebook SDK 3.0 for Android?

recently I have been working on Facebook SDK 3.0 for Android.
While everything was done smoothly, I found the following issue.
When the user presses a facebook Login button on a device where native Facebook app is not installed, a webview login activity appears. After logging in, the login page appears again even when the app requests user's permissions. (This is a known issue according to Facebook http://developers.facebook.com/bugs/333926600053215)
So, until Facebook fixes this issue, what I want to do is to detect whether the user has FB app installed on his device, and if not I want to show my customized webview that handles login process.
Since I have all the source codes in Facebook library project, I think I can customize that but the question is, how should this be done?
If I make a change on one of those files in the library projects, will it be automatically applied to the main project that uses this library project? What would be an efficient way to customize the facebook library project?
I faced the same issue and partially solved it: roughly, i attempt to obtain login with publish permissions, if it's rejected then the fb application's installed and then i request read-only then publish, if it's not rejected then you get the login with publish permissions coming up right after it and you're good to go.
problems with this solution:
1) 3 user interactions instead if 2 if the fb app's installed.
2) bug if cancelling the login with a webview (a second one appears), though i think this one's solveable, i didn't have time to try.
sorry for quick/curt reply.

Android App Inventor: How do I set up a HTTPS connection?

I am making an app, with a very limited audience that logs into my mini website. It uses a HTTPS login dialog box though to access the site. How would I implement a setup where the user logs in with a username and password box on the first screen, submits the info with a button, which is used to log into the website, and then the user is taken to the next screen where there is a web viewer that is logged into and viewing the protected website.
This needs to be on Android and made in App Inventor, and I am quite clueless in programming, with little experience beyond hello world! :D I can string together some basic apps but here I am stumped. Please help! I just need some clear instruction really on what to do.
Though your question is nearly one year old, I pass you a solution in case you still require it. Like you I came accross the need of creating a login dialog in AppInventor and none of the solutions I found on the web met completely my idea so I decided to develop it on my own.
The solution can be used as a template for any new app and it provides the following functionalities:
Initial login window, with buttons allowing to register or remember password (by email)
User's information stored in a tinywebDB, with basic encryption for password
Integration with Google accounts, allowing the user to inform his google account instead of having to remember yet another password
Profile window, allowing the user to modify its setting after its registration
The sources are here. I've also created a tutorial on my website. And here is a real app using this template.

Problems with PhoneGap with Facebook Connect integration

I am trying to use the new PhoneGap Facebook Connect plugin, which is supposed to work with just a few lines of code. https://github.com/davejohnson/phonegap-plugin-facebook-connect
PhoneGap v1.2.0
In Eclipse, I have built the sample project included with the plugin and have added my app_id and app_secret and put all files where necessary. It seems like I have done everything right, but the buttons do the following:
Login: Alerts "not logged in" (even though I am logged in to Facebook both through the app and the browser)
Me: Alerts "An active access token mst be used to query information about the current user. Type: OAuthException
Get Session: Alerts "undefined"
Get Login: Loads a facebook page in the browser which says "an error occurred. Please try again later"
Logout: Alerts "auth.statusChange event"
What have I done wrong? I have a killer app waiting to be released which is dependent on this Facebook integration and I'm anxious to release it!
The problem is the phonegap core implementation.
The official Android Facebook plugin opens a dialog for facebook authentication.
This all happens threaded within phonegap.
They used however plain threading instead of AsyncTask driven threads.
The AsyncTask concept allows background tasks to be displayed within the main UI thread.
I have created a fork for phonegap 1.2 called tmaus.
Using the forked phonegap, you would be able to properly login into facebook,
but the handling of the session_data is still broken.
Have a look at gitbub/callback-android
You will find my fork (tmaus) which has not been confirmed yet.

More advanced android facebook example

I'm having some problems with facebook integration on my android app. I've looked at the examples that come with the api and i can do the things shown in those ok. But i'm having problems with other things such as getting single sign on to work properly, authentication across multiple activities in the app and loading a facebook page (non-api call) without being asked to log in again.
Anyone have examples that show these?
When making API calls, you usually need to include the access_token parameter that was issued when the user authenticated. This is how facebook knows who you are when you make requests.
Similarly, when loading facebook pages (not using the API), you have to remember to send the cookies Facebook sent when the user logged in. Normally the browser keeps track of these automatically, but in your program or app you might have to handle them manually.
I don't have experience with Android specifically, and I don't know what you're using to load and render facebook pages, but knowing how facebook is keeping track of logged-in users should give you an idea of where to start. A google search or two should get you on your way.
Go to facebook.java class and change package name com.facebook.katana to com.facebook.katanaaa or any one of your own choice. This worked for me .

Categories

Resources