I'm trying to build an Android test application integrated to the SalesForce platform. I have downloaded the SDK from here, and imported it to my workspace. Everything works fine except my test app, even the RestExplorer sample app they have provided along with the SDK work without problem. As a first step, what I tried was to clone the basic features (just login as of now) from the RestExplorer app. The following are my important files.
public class Home extends Activity {
private PasscodeManager passcodeManager;
private RestClient client;
private TokenRevocationReceiver tokenRevocationReceiver;
RestClient getClient() {
return client;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
passcodeManager = SalesforceSDKManager.getInstance().getPasscodeManager();
tokenRevocationReceiver = new TokenRevocationReceiver(this);
setContentView(R.layout.activity_home);
}
@Override
public void onResume() {
super.onResume();
registerReceiver(tokenRevocationReceiver, new IntentFilter(ClientManager.ACCESS_TOKEN_REVOKE_INTENT));
if (passcodeManager.onResume(this)) { // Bring up passcode screen if needed
String accountType = SalesforceSDKManager.getInstance().getAccountType(); // Login options
new ClientManager(this, accountType, SalesforceSDKManager.getInstance().getLoginOptions(), SalesforceSDKManager.getInstance().shouldLogoutWhenTokenRevoked()).getRestClient(this, new RestClientCallback() { // Get a rest client
@Override
public void authenticatedRestClient(RestClient client) {
if (client == null) {
SalesforceSDKManager.getInstance().logout(Home.this);
return;
}
Home.this.client = client;
}
});
}
}
@Override
protected void onPause() {
passcodeManager.onPause(this);
unregisterReceiver(tokenRevocationReceiver);
super.onPause();
}
}
I have added the permissions as required
<permission android:name="com.salesforce.samples.restexplorer.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.salesforce.samples.restexplorer.C2D_MESSAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS"/>
<uses-permission android:name="android.permission.ACCOUNT_MANAGER"/>
And extended the application object to give a call to init();
public class MyApp extends Application {
@Override
public void onCreate() {
super.onCreate();
SalesforceSDKManager.initNative(getApplicationContext(), new KeyImpl(), Home.class);
}
}
Now, I'm getting the error in my Android debug log. The log as I see is attached below. It keep the activity restarting till I forcefully kill the application.
11-08 15:56:23.883: I/ClientManager:getRestClient(9334): No account of type com.salesforce.androisdk found
11-08 15:56:23.898: W/AccMgrCallback:run(9334): android.accounts.AuthenticatorException: bind failure
11-08 15:56:23.898: W/AccMgrCallback:run(9334): at android.accounts.AccountManager.convertErrorToException(AccountManager.java:1726)
11-08 15:56:23.898: W/AccMgrCallback:run(9334): at android.accounts.AccountManager.access$400(AccountManager.java:144)
11-08 15:56:23.898: W/AccMgrCallback:run(9334): at android.accounts.AccountManager$AmsTask$Response.onError(AccountManager.java:1572)
11-08 15:56:23.898: W/AccMgrCallback:run(9334): at android.accounts.IAccountManagerResponse$Stub.onTransact(IAccountManagerResponse.java:69)
11-08 15:56:23.898: W/AccMgrCallback:run(9334): at android.os.Binder.execTransact(Binder.java:388)
11-08 15:56:23.898: W/AccMgrCallback:run(9334): at dalvik.system.NativeStart.run(Native Method)
Do anyone have any idea about this isse? It is such a basic app, I was not expecting anything unusual. Did I do anything wrong in my app?