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
 Include
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) {
    android.webkit.WebView.setWebContentsDebuggingEnabled(true);
}
Full Code

package com.achievers.app;

import android.annotation.SuppressLint;
import android.app.Application;

import com.salesforce.androidsdk.smartstore.app.SalesforceSDKManagerWithSmartStore;
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 {

       @Override
        public void onCreate() {
         super.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) {
          android.webkit.WebView.setWebContentsDebuggingEnabled(true);
       }

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

        }
}


After that go to Chrome 
then


















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.