Since Chrome has an awesome feature for remote debugging,
I am wondering how this could help in developing in Worklight.
In the following docs they say to debug the contents of your WebView, you need to enable it programmatically from within your application by calling setWebContentsDebuggingEnabled, a static method on the WebView class.
Where can I find this class and will this be beneficial to do it in Worklight?
https://developers.google.com/chrome-developer-tools/docs/remote-debugging?hl=nl#debugging-webviews
Please note that WebView debugging is only relevant for Android 4.4 "KitKat" and not to any prior version of the Android OS.
To debug your Chromium WebView in a Worklight application with the Android environment,
Open the Android SDK and update to API Level 19.
You will of course need either a device or emulator running this version.
Make sure that in yourAppName\android\native\AndroidManifest.xml you add support for targetSdkVersion=19.
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="19" />
Change the Build Target to Android 4.4:
Right-click on the generated Android project > Properties > Android > Build Target
Open yourAppName\android\native\src\com\yourAppName\yourAppName.java and
Import the following:
import android.os.Build;
import android.util.Log;
import android.content.pm.ApplicationInfo;
import android.webkit.WebView;
Add the following to the onCreate() function:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){
if(0 != (getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE)){
WebView.setWebContentsDebuggingEnabled(true);
}
}
The rest of the steps are as described in the Google documentation page.
I don't have an Android device to verify this, so please try.
As for whether it is beneficial or not, another debugging alternative can't hurt. It is up to you to decide if it's good or not, for you.
Related
First of all, thank you for your help.
Here is my problem.
I have made a custom system service (it does connect through the binder, and hooks into the system server, then into the HAL, etc). One of the main commands is isBacklightOn(). I also ran the make update-api to include it in my ROM build.
I am now ready to test the functionality using an app. I am using the following code:
import android.os.BacklightManager; //My service manager name
...
BacklightManager bm = (BacklightManager) getSystemService(BACKLIGHT_SERVICE);
...
if(!bm.isBacklightOn()) {
//Turn it on.
} else {
//Other Things...
}
My problem occurs because Android Studio will not build the application due to not knowing what the BacklightManager is. How can I build this application to test my code? (import something into Android Manager, force a build ignoring errors, etc.)
It looks like the solution is to build a custom SDK within the AOSP build environment. And then import that into Android Studio
I am developing an app in Android Studio with target for API 22. I have tried to use the Log class with the method d() but I did not find it. The helper shows only Log()...
What am I missing?
Just import the library import android.util.Log;
And just tips: use alt+space and alt+enter feature from Android Studio
Note:
Alt + Enter = Project quick fix (show intention actions and quick fixes)
I have an Android 2.2 targeted library project, whose MyLibraryGooglePlusSocialPlugin.java has a import com.google.android.gms.plus.GooglePlusUtil; being failed to compile (GooglePlusUtil cannot be resolved), while others are okay:
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesClient;
import com.google.android.gms.common.Scopes;
import com.google.android.gms.plus.PlusClient;
import com.google.android.gms.plus.PlusClient.OnPeopleLoadedListener;
import com.google.android.gms.plus.PlusClient.OnPersonLoadedListener;
import com.google.android.gms.plus.PlusShare;
import com.google.android.gms.plus.model.people.Person;
import com.google.android.gms.plus.model.people.PersonBuffer;
I've updated the related Google services through Android SDK manager today, and set the build path and dependencies.
The GooglePlusUtils class has been removed because you no longer need it. All of the existing error handling functionality has been integrated in a way that doesn't require developer intervention.
As an example of how you can migrate from using this (now deprecated) class, see the following change from the Google+ Photohunt Android client sample that resolves the issue:
https://github.com/gguuss/gplus-photohunt-client-android/commit/090c22b4721fde6859361aca210823822c218da8
I work it around by downgrading to a previous version where the AndroidManifest.xml in the google-play-services_lib goes like this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.android.gms"
android:versionCode="3159130"
android:versionName="3.1.59 (744626-30)" >
<uses-sdk android:minSdkVersion="8"/>
</manifest>
UPDATE
I downgrade the library by reloading a lower version that was saved in my local disk. No idea how to downgrade through Android SDK manager.
Their documentation has not changed online, but it is indeed missing form the jar. I would look for a copy of the last version and use it for the time being.
** UPDATE **
You can do the same things with the GooglePlayServicesUtil and checking to see if they user has the correct package name for Google Plus.
The old GooglePlusUtil + error codes are not needed now, because even if the device has not installed GooglePlus application, GooglePlay services provides connection to user account. You can only check if GooglePlay services is present and updated using GooglePlayServicesUtil.isGooglePlayServicesAvailable and hide UI field with GooglePlus. In other case connection to user (GooglePlus) account will be made.
I tried a example provided in the, Android app testing through Selenium, i have included the selenium-java library and android-webdriver apk also installed in emulator, but when try with the sample code provide in the forum i got error in AnroidWebDriver import, in selenium library only AndroidDriver class is available, so where could i get the AdroidWebDriver jar. Plz assit.
Note: Selenium library is very latest one.
import android.test.ActivityInstrumentationTestCase2;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.android.AndroidWebDriver;
import simple.app.SimpleAppActivity;
public class SimpleGoogleTest extends ActivityInstrumentationTestCase2<SimpleAppActivity> {
private WebDriver driver;
private WebDriver googledriver;
public SimpleGoogleTest() {
super("simple.app", SimpleAppActivity.class);
}
#Override
protected void setUp() throws Exception {
driver = new AndroidWebDriver(getActivity());
}
........................,,,,,
}
There are two variations of the Android Driver:
AndroidDriver() which you use on your Personal Computer e.g. your
laptop, workstation, etc. which provides the richest and most
complete set of capabilities for your tests.
AndroidWebDriver() which runs on your Android device, this wraps a WebView component to provide the basic core functionality.
The example code that comes with the Android SDK and the optional support for Selenium/WebDriver runs some basic tests on the device. The tests are compiled as an Android program which extend ActivityInstrumentationTestCase2. AndroidWebDriver() is contained in sdk/extras/google/webdriver/android_webdriver_library.jar (and the Javadocs are in sdk/extras/google/webdriver/android_webdriver_library-srcs.jar
So, if you want to run your tests on your Android device, then you need to include android-webdriver-library.jar in your project. Perhaps the simplest way is to copy this jar into your test project's libs folder.
However, if you would like to run your tests on your Personal Computer you can modify the example code to use AndroidDriver instead of AndroidWebDriver. You also need to change your base class e.g. to use Junit 3 or Junit 4. I have posted a sample test as an answer to another question on Stack Overflow here Having difficulty in finding Elements using Xpath and CSS in Selenium Android Webdriver Testing
I want to switch cm profile manager profiles from within my app.
I found that i need to get the service from ProfileManager, so after digging in cm10 sources i figured
import android.app.IProfileManager;
import android.app.ProfileManager;
will do the deal, but how do i have to import this in eclipse?
Do I have to download and include full cm10 sources?
Just in case someone is still trying to find a way to control CM Profiles:
CM introduced it's platform SDK, which allows you to do just that.
https://github.com/CyanogenMod/cm_platform_sdk/wiki
It's also on maven central
dependencies {
compile 'org.cyanogenmod:platform.sdk:4.+'
}