Thursday, April 2, 2015

Inspect Html elements and console for your Android Hybrid Apps

Now Inspect Html elements and track console as well for your Android Hybrid App as you do for your HTML pages in browser.
You just need chrome browser and some changes in Application’s native code
import android.annotation.SuppressLint;
On application start class
Also use @SuppressLint("NewApi") before class access definition
Use below code inside on create method
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
Full Code


import android.annotation.SuppressLint;

import com.salesforce.androidsdk.ui.LoginActivity;

 * Included @SuppressLint("NewApi") for enabling webview showing on inspect element with chrome
 * @author Kunal Bindal
 * Date: 24-03-2015
@SuppressLint("NewApi") public class MyApp extends Application {

        public void onCreate() {
          * For webview showing on inspect element with chrome
          * @author Kunal Bindal
          * Date: 24-03-2015
          * */
         if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {

         SalesforceSDKManagerWithSmartStore.initHybrid(getApplicationContext(), new KeyImpl(), SplashScreenDemoActivity.class, LoginActivity.class);


After that go to Chrome 

Capture images in android hybrid mobile apps

Are you unable to capture images from android hybrid mobile app ?

Or cordova take picture not working.

Here is the solution

If you are unable to capture images from some of the devices from your android application.

Like capture image for nexus tab which uses Android version greater than 4.4.0
Check out following permissions:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Also some user features:

We need to give write file permissions as well. Which we didn't have to give in previous versions as before it stores captured images in buffer but in some devices it first need to store images in File System then from there it picks.

Monday, March 2, 2015

Salesforce Calling web service after authentication

Request to Salesforce
The external App will need to make an HTTP Request with the following values:
• HTTP method: ‘POST’
• Endpoint URL: [Salesforce login domain] + ‘/services/oauth2/token’
• Body:
o username: [Salesfore user’s username]
o password: [Salesfore user’s password]
o client_id: [Salesforce Connected App’s Consumer Key]
o client_secret: [Salesforce Connected App’s Consumer Secret]
o grant_type : ‘password’

The Salesforce login domain will be either:
• - if interacting with the Production org
• - if interacting with a Sandbox org
Connected App for the Customer Sync

Sending Request for authentication
1.       Enter following
a.       URL Field :- /services/oauth2/token
b.      Body Field :-grant_type=password&client_id=YOUR_CONSUMER_KEY&client_secret=YOUR_CONSUMER_SECRET&username=YOUR_USER_NAME&password=YOUR_PASSWORD_WITH_SECURITY_TOKEN
c.       Click on ‘Headers’ button, enter following in headers field:-
Content-Type: application/x-www-form-urlencoded

Accept: application/json

Using instance url and access token REST API need to be called
In response it will give