Live Wall paper force closes - android

My Live wall app force closes when clicked on the Settings button.
wall_setting.xml
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<ListPreference
android:key="time_interval"
android:title="#string/app_name"
android:summary="something"
android:defaultValue="3000"
android:entries="#array/updateInterval"
android:entryValues="#array/updateIntervalValues"
/>
</PreferenceScreen>
main.xml
<?xml version="1.0" encoding="utf-8"?>
<wallpaper xmlns:android="http://schemas.android.com/apk/res/android"
android:thumbnail="#drawable/ic_launcher"
android:settingsActivity="com.zacharia.lunar.WallService"
android:description="#string/wall_desc" />
manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.zacharia.lunar"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="15" />
<uses-feature
android:name="android.software.live_wallpaper"
android:required="true"></uses-feature>
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<service
android:name="com.zacharia.lunar.WallService"
android:enabled="true"
android:permission="android.permission.BIND_WALLPAPER">
<intent-filter>
<action android:name="android.service.wallpaper.WallpaperService"></action>
</intent-filter>
<meta-data
android:name="android.service.wallpaper"
android:resource="#xml/main"></meta-data>
</service>
<activity
android:name="com.zacharia.lunar.SettingActivity"
android:label="#string/title_activity_main"
android:theme="#android:style/Theme.Light.WallpaperSettings"
android:exported="true">
</activity>
</application>
</manifest>
Errors
09-14 20:36:53.491: E/AndroidRuntime(542): java.lang.IllegalStateException: Could not execute method of the activity
09-14 20:36:53.491: E/AndroidRuntime(542): at android.view.View$1.onClick(View.java:2031)
09-14 20:36:53.491: E/AndroidRuntime(542): at android.view.View.performClick(View.java:2364)
09-14 20:36:53.491: E/AndroidRuntime(542): at android.view.View.onTouchEvent(View.java:4179)
09-14 20:36:53.491: E/AndroidRuntime(542): at android.widget.TextView.onTouchEvent(TextView.java:6541)
09-14 20:36:53.491: E/AndroidRuntime(542): at android.view.View.dispatchTouchEvent(View.java:3709)
09-14 20:36:53.491: E/AndroidRuntime(542): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
09-14 20:36:53.491: E/AndroidRuntime(542): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
09-14 20:36:53.491: E/AndroidRuntime(542): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
09-14 20:36:53.491: E/AndroidRuntime(542): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)
09-14 20:36:53.491: E/AndroidRuntime(542): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
09-14 20:36:53.491: E/AndroidRuntime(542): at com.android.wallpaper.livepicker.LiveWallpaperPreview.dispatchTouchEvent(LiveWallpaperPreview.java:199)
09-14 20:36:53.491: E/AndroidRuntime(542): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
09-14 20:36:53.491: E/AndroidRuntime(542): at android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
09-14 20:36:53.491: E/AndroidRuntime(542): at android.os.Handler.dispatchMessage(Handler.java:99)
09-14 20:36:53.491: E/AndroidRuntime(542): at android.os.Looper.loop(Looper.java:123)
09-14 20:36:53.491: E/AndroidRuntime(542): at android.app.ActivityThread.main(ActivityThread.java:4363)
09-14 20:36:53.491: E/AndroidRuntime(542): at java.lang.reflect.Method.invokeNative(Native Method)
09-14 20:36:53.491: E/AndroidRuntime(542): at java.lang.reflect.Method.invoke(Method.java:521)
09-14 20:36:53.491: E/AndroidRuntime(542): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
09-14 20:36:53.491: E/AndroidRuntime(542): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
09-14 20:36:53.491: E/AndroidRuntime(542): at dalvik.system.NativeStart.main(Native Method)
09-14 20:36:53.491: E/AndroidRuntime(542): Caused by: java.lang.reflect.InvocationTargetException
09-14 20:36:53.491: E/AndroidRuntime(542): at com.android.wallpaper.livepicker.LiveWallpaperPreview.configureLiveWallpaper(LiveWallpaperPreview.java:113)
09-14 20:36:53.491: E/AndroidRuntime(542): at java.lang.reflect.Method.invokeNative(Native Method)
09-14 20:36:53.491: E/AndroidRuntime(542): at java.lang.reflect.Method.invoke(Method.java:521)
09-14 20:36:53.491: E/AndroidRuntime(542): at android.view.View$1.onClick(View.java:2026)
09-14 20:36:53.491: E/AndroidRuntime(542): ... 20 more
09-14 20:36:53.491: E/AndroidRuntime(542): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.zacharia.lunar/com.zacharia.lunar.WallService}; have you declared this activity in your AndroidManifest.xml?
09-14 20:36:53.491: E/AndroidRuntime(542): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404)
09-14 20:36:53.491: E/AndroidRuntime(542): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
09-14 20:36:53.491: E/AndroidRuntime(542): at android.app.Activity.startActivityForResult(Activity.java:2749)
09-14 20:36:53.491: E/AndroidRuntime(542): at android.app.Activity.startActivity(Activity.java:2855)
09-14 20:36:53.491: E/AndroidRuntime(542): ... 24 more

In main.xml
android:settingsActivity="com.zacharia.lunar.WallService"
should read;
android:settingsActivity="com.zacharia.lunar.SettingActivity"

Related

can't add plugin org.apache.cordova.geolocation.GeoBroker

I am having some problems with PhoneGap 3.0
Everything was working as should on PhoneGap 2.9
Now I upgraded to 3.0 And created a new PhoneGap Project.
$> phonegap create new_project
added to config.xml :
<feature name="http://api.phonegap.com/1.0/geolocation"/>
and for index.html I used the full example from http://docs.phonegap.com/en/edge/cordova_geolocation_geolocation.md.html#geolocation.getCurrentPosition_full_example
then
$> phonegap build android
I imported the project to Eclipse and checked the following :
AndroidManifest.xml has
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
xml/config.xml has
<feature name="Geolocation">
<param name="android-package" value="org.apache.cordova.geolocation.GeoBroker" />
</feature>
I also used this cmd :
$> phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation.git
and that created the package src/
org.apache.cordova.geolocation
now when I run my app.
I got the Following errors :
I/System.out(15155): Error adding plugin org.apache.cordova.geolocation.GeoBroker.
D/PluginManager(15155): exec() call to unknown plugin: Geolocation
error Trace :
09-14 18:07:50.185: W/System.err(28211): java.lang.ClassNotFoundException: org.apache.cordova.geolocation.GeoBroker
09-14 18:07:50.195: W/System.err(28211): at java.lang.Class.classForName(Native Method)
09-14 18:07:50.195: W/System.err(28211): at java.lang.Class.forName(Class.java:217)
09-14 18:07:50.195: W/System.err(28211): at java.lang.Class.forName(Class.java:172)
09-14 18:07:50.195: W/System.err(28211): at org.apache.cordova.PluginEntry.getClassByName(PluginEntry.java:117)
09-14 18:07:50.195: W/System.err(28211): at org.apache.cordova.PluginEntry.createPlugin(PluginEntry.java:93)
09-14 18:07:50.195: W/System.err(28211): at org.apache.cordova.PluginManager.getPlugin(PluginManager.java:267)
09-14 18:07:50.205: W/System.err(28211): at org.apache.cordova.PluginManager.execHelper(PluginManager.java:221)
09-14 18:07:50.205: W/System.err(28211): at org.apache.cordova.PluginManager.exec(PluginManager.java:216)
09-14 18:07:50.205: W/System.err(28211): at org.apache.cordova.ExposedJsApi.exec(ExposedJsApi.java:53)
09-14 18:07:50.205: W/System.err(28211): at android.webkit.JWebCoreJavaBridge.sharedTimerFired(Native Method)
09-14 18:07:50.205: W/System.err(28211): at android.webkit.JWebCoreJavaBridge.sharedTimerFired(Native Method)
09-14 18:07:50.205: W/System.err(28211): at android.webkit.JWebCoreJavaBridge.fireSharedTimer(JWebCoreJavaBridge.java:107)
09-14 18:07:50.215: W/System.err(28211): at android.webkit.JWebCoreJavaBridge.handleMessage(JWebCoreJavaBridge.java:136)
09-14 18:07:50.215: W/System.err(28211): at android.os.Handler.dispatchMessage(Handler.java:99)
09-14 18:07:50.215: W/System.err(28211): at android.os.Looper.loop(Looper.java:154)
09-14 18:07:50.215: W/System.err(28211): at android.webkit.WebViewCore$WebCoreThread.run(WebViewCore.java:780)
09-14 18:07:50.215: W/System.err(28211): at java.lang.Thread.run(Thread.java:864)
09-14 18:07:50.225: W/System.err(28211): Caused by: java.lang.NoClassDefFoundError: org/apache/cordova/geolocation/GeoBroker
09-14 18:07:50.225: W/System.err(28211): ... 17 more
09-14 18:07:50.225: W/System.err(28211): Caused by: java.lang.ClassNotFoundException: org.apache.cordova.geolocation.GeoBroker
09-14 18:07:50.225: W/System.err(28211): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
09-14 18:07:50.225: W/System.err(28211): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
09-14 18:07:50.225: W/System.err(28211): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
09-14 18:07:50.235: W/System.err(28211): ... 17 more
and the Javascript function onError()
alert with code:null & message:
Any suggestions ?
Thank you in Advance
I thinks it's strange, but it was solved by following the steps from this link.
You need to download Cordova Android from here.
Then run these commands to build cordova-dev.jar:
android update project -p . -t android-17
ant jar
This will create cordova-dev.jar. Alternatively you can download the jar from here.
Copy cordova-dev.jar to libs folder in the Android project in eclipse and add it to the project classpath.
Now all the compilation errors will be resolved, and the project will compile successfully.

BluetoothChat example: NullPointerException [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
getActionBar returns null
Complete Android noob. I am trying to run the BluetoothChat example from a Galaxy S3, and it appears to crash the moment the application is run.
Here is the LogCat output:
09-14 15:47:23.400: E/AndroidRuntime(6098): FATAL EXCEPTION: main
09-14 15:47:23.400: E/AndroidRuntime(6098): java.lang.NullPointerException
09-14 15:47:23.400: E/AndroidRuntime(6098): at com.example.android.BluetoothChat.BluetoothChat.setStatus(BluetoothChat.java:235)
09-14 15:47:23.400: E/AndroidRuntime(6098): at com.example.android.BluetoothChat.BluetoothChat.access$4(BluetoothChat.java:233)
09-14 15:47:23.400: E/AndroidRuntime(6098): at com.example.android.BluetoothChat.BluetoothChat$2.handleMessage(BluetoothChat.java:260)
09-14 15:47:23.400: E/AndroidRuntime(6098): at android.os.Handler.dispatchMessage(Handler.java:99)
09-14 15:47:23.400: E/AndroidRuntime(6098): at android.os.Looper.loop(Looper.java:137)
09-14 15:47:23.400: E/AndroidRuntime(6098): at android.app.ActivityThread.main(ActivityThread.java:4514)
09-14 15:47:23.400: E/AndroidRuntime(6098): at java.lang.reflect.Method.invokeNative(Native Method)
09-14 15:47:23.400: E/AndroidRuntime(6098): at java.lang.reflect.Method.invoke(Method.java:511)
09-14 15:47:23.400: E/AndroidRuntime(6098): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:993)
09-14 15:47:23.400: E/AndroidRuntime(6098): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:760)
09-14 15:47:23.400: E/AndroidRuntime(6098): at dalvik.system.NativeStart.main(Native Method)
Code is exactly per the example in the SDK:
private final void setStatus(int resId) {
final ActionBar actionBar = getActionBar();
actionBar.setSubtitle(resId);
}
It appears getActionBar returns null. What might I be doing incorrectly?
This is only the 2nd Android app I have run, so go easy on me :)
Cheers
Solution found here: getActionBar returns null
this needs to go to the onCreate() method in bluetoothChat.java
getWindow().requestFeature(Window.FEATURE_ACTION_BAR);

android 3G permission

i wrote in the manifest file this permissions:
</application>
<uses-permission android:name="android.permission.CALL_PHONE"></uses-permission>
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-feature android:name="android.hardware.wifi" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
<uses-permission android:name="android.permission.UPDATE_DEVICE_STATS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
</manifest>
and when i start the app it wrote: "unfortanely the app stopped" and exit from it
in Logcat i saw the line that the program fail is:
Class conmanClass;
Field iConnectivityManagerField;
iConnectivityManagerField = conmanClass.getDeclaredField("mService");
what is the problem?can anyone help me to fix it?
this is the logcat:
09-14 09:11:49.493: E/AndroidRuntime(1669): FATAL EXCEPTION: main
09-14 09:11:49.493: E/AndroidRuntime(1669): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.voicerecognitiondemo/com.example.voicerecognitiondemo.VoiceRecognitionDemo}: java.lang.NullPointerException
09-14 09:11:49.493: E/AndroidRuntime(1669): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
09-14 09:11:49.493: E/AndroidRuntime(1669): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
09-14 09:11:49.493: E/AndroidRuntime(1669): at android.app.ActivityThread.access$600(ActivityThread.java:123)
09-14 09:11:49.493: E/AndroidRuntime(1669): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
09-14 09:11:49.493: E/AndroidRuntime(1669): at android.os.Handler.dispatchMessage(Handler.java:99)
09-14 09:11:49.493: E/AndroidRuntime(1669): at android.os.Looper.loop(Looper.java:137)
09-14 09:11:49.493: E/AndroidRuntime(1669): at android.app.ActivityThread.main(ActivityThread.java:4424)
09-14 09:11:49.493: E/AndroidRuntime(1669): at java.lang.reflect.Method.invokeNative(Native Method)
09-14 09:11:49.493: E/AndroidRuntime(1669): at java.lang.reflect.Method.invoke(Method.java:511)
09-14 09:11:49.493: E/AndroidRuntime(1669): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
09-14 09:11:49.493: E/AndroidRuntime(1669): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
09-14 09:11:49.493: E/AndroidRuntime(1669): at dalvik.system.NativeStart.main(Native Method)
09-14 09:11:49.493: E/AndroidRuntime(1669): Caused by: java.lang.NullPointerException
09-14 09:11:49.493: E/AndroidRuntime(1669): at com.example.voicerecognitiondemo.VoiceRecognitionDemo.onCreate(VoiceRecognitionDemo.java:55)
09-14 09:11:49.493: E/AndroidRuntime(1669): at android.app.Activity.performCreate(Activity.java:4465)
09-14 09:11:49.493: E/AndroidRuntime(1669): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
09-14 09:11:49.493: E/AndroidRuntime(1669): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
09-14 09:11:49.493: E/AndroidRuntime(1669): ... 11 more
It seems you forgot to initialize Class conmanClass; do it and try again
like this
conmanClass=new Class(); //if you are using default constructor then else use the proper constroctor to initialize you conmanClass

How to start InputMethodService using Broadcastreceiver or Intent in android?

We have an 'InputMethodService' as a stand alone application now what we want to start this InputMethodService for a particular activity in another application.
We tried using broadcast receiver but it is giving following error:
Intent myService = new Intent(context, Cs_key.class);
context.startService(myService);
LOGCATE:
-
29 11:06:51.624: ERROR/AndroidRuntime(24087): FATAL EXCEPTION: main
09-29> 09 11:06:51.624: ERROR/AndroidRuntime(24087): java.lang.RuntimeException: Unable to start receiver com.ashwin.demo.keyboard.KeyboardReceiver: java.lang.SecurityException: Not allowed to start service Intent { cmp=com.ashwin.demo.keyboard/.Cs_key } without permission android.permission.BIND_INPUT_METHOD
09-29 11:06:51.624: ERROR/AndroidRuntime(24087): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2821)
09-29 11:06:51.624: ERROR/AndroidRuntime(24087): at android.app.ActivityThread.access$3200(ActivityThread.java:125)
09-29 11:06:51.624: ERROR/AndroidRuntime(24087): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2083)
09-29 11:06:51.624: ERROR/AndroidRuntime(24087): at android.os.Handler.dispatchMessage(Handler.java:99)
09-29 11:06:51.624: ERROR/AndroidRuntime(24087): at android.os.Looper.loop(Looper.java:123)
09-29 11:06:51.624: ERROR/AndroidRuntime(24087): at android.app.ActivityThread.main(ActivityThread.java:4627)
09-29 11:06:51.624: ERROR/AndroidRuntime(24087): at java.lang.reflect.Method.invokeNative(Native Method)
09-29 11:06:51.624: ERROR/AndroidRuntime(24087): at java.lang.reflect.Method.invoke(Method.java:521)
09-29 11:06:51.624: ERROR/AndroidRuntime(24087): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-29 11:06:51.624: ERROR/AndroidRuntime(24087): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-29 11:06:51.624: ERROR/AndroidRuntime(24087): at dalvik.system.NativeStart.main(Native Method)
09-29 11:06:51.624: ERROR/AndroidRuntime(24087): Caused by: java.lang.SecurityException: Not allowed to start service Intent { cmp=com.ashwin.demo.keyboard/.Cs_key } without permission android.permission.BIND_INPUT_METHOD
09-29 11:06:51.624: ERROR/AndroidRuntime(24087): at android.app.ContextImpl.startService(ContextImpl.java:832)
09-29 11:06:51.624: ERROR/AndroidRuntime(24087): at android.content.ContextWrapper.startService(ContextWrapper.java:336)
09-29 11:06:51.624: ERROR/AndroidRuntime(24087): at android.content.ContextWrapper.startService(ContextWrapper.java:336)
09-29 11:06:51.624: ERROR/AndroidRuntime(24087): at com.ashwin.demo.keyboard.KeyboardReceiver.onReceive(KeyboardReceiver.java:18)
09-29 11:06:51.624: ERROR/AndroidRuntime(24087): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2810)
menifestfile
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1"
android:versionName="1.0" package="com.ashwin.demo.keyboard">
<uses-permission android:name="android.permission.BIND_INPUT_METHOD"/>
<application android:label="#string/app_name" >
<service android:name="Cs_key" android:exported="true"
android:permission="android.permission.BIND_INPUT_METHOD">
<intent-filter>
<action android:name="android.view.InputMethod" />
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
<meta-data android:name="android.view.im" android:resource="#xml/method" />
</service>
<receiver android:name=".KeyboardReceiver"
android:permission="android.permission.BIND_INPUT_METHOD">
<intent-filter>
<action android:name="android.intent.action.TIME_SET"></action>
</intent-filter>
</receiver>
</application>
</manifest>

Unable to load webpage using WebView in Android

I have recently taken up Android Development and I was looking to using the WebView display webpages. I picked up from the sample that was given on Google site and for some reason the emulator kept saying page was not available. I searched in StackOverflow and found links relating to WebViewClient. I tried that also but no luck there, I have checked multiple times about the manifest entry for internet permission and its there. As a test I ran the browser available within the emulator and sure enough my firewall popped up a question on whether to allow it access or not. The pop up never came to me when I was running it from program. The code that I have is what is there Google pages
mWebView = (WebView) findViewById(R.id.webview);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl("http://www.google.com");
mWebView.setWebViewClient(new HelloWebViewClient());
private class HelloWebViewClient extends WebViewClient {
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
I tried loading simple html directly using loadData and it worked fine. I am at loss as to what is happening and how this can be resolved. I would appreciate any help on this.
Adding the Android Manifest here
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.hellowebview"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".HelloWebView"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<uses-permission android:name="android.permission.INTERNET" />
</application>
</manifest>
To check if its just a WebView thingy, I tried accessing the internet using httpGet and httpResonse classes and got the same problem, the code was not able to connect to the given site. It failed stating the below
05-10 00:37:53.191: WARN/System.err(294): java.net.UnknownHostException: feeds.feedburner.com
05-10 00:37:53.230: WARN/System.err(294): at java.net.InetAddress.lookupHostByName(InetAddress.java:513)
05-10 00:37:53.230: WARN/System.err(294): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:278)
05-10 00:37:53.230: WARN/System.err(294): at java.net.InetAddress.getAllByName(InetAddress.java:242)
05-10 00:37:53.250: WARN/System.err(294): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:136)
05-10 00:37:53.250: WARN/System.err(294): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
05-10 00:37:53.250: WARN/System.err(294): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
05-10 00:37:53.271: WARN/System.err(294): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:348)
05-10 00:37:53.271: WARN/System.err(294): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
05-10 00:37:53.280: WARN/System.err(294): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
05-10 00:37:53.291: WARN/System.err(294): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
05-10 00:37:53.301: WARN/System.err(294): at com.example.hellowebview.HelloWebView.onCreate(HelloWebView.java:43)
05-10 00:37:53.301: WARN/System.err(294): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-10 00:37:53.309: WARN/System.err(294): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
05-10 00:37:53.322: WARN/System.err(294): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
05-10 00:37:53.330: WARN/System.err(294): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
05-10 00:37:53.340: WARN/System.err(294): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
05-10 00:37:53.350: WARN/System.err(294): at android.os.Handler.dispatchMessage(Handler.java:99)
05-10 00:37:53.350: WARN/System.err(294): at android.os.Looper.loop(Looper.java:123)
05-10 00:37:53.361: WARN/System.err(294): at android.app.ActivityThread.main(ActivityThread.java:4627)
05-10 00:37:53.361: WARN/System.err(294): at java.lang.reflect.Method.invokeNative(Native Method)
05-10 00:37:53.372: WARN/System.err(294): at java.lang.reflect.Method.invoke(Method.java:521)
05-10 00:37:53.380: WARN/System.err(294): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-10 00:37:53.380: WARN/System.err(294): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-10 00:37:53.401: WARN/System.err(294): at dalvik.system.NativeStart.main(Native Method)
05-10 00:37:56.773: WARN/ActivityManager(58): Launch timeout has expired, giving up wake lock!
05-10 00:37:58.083: WARN/ActivityManager(58): Activity idle timeout for HistoryRecord{44fc9108 com.example.hellowebview/.HelloWebView}
05-10 00:38:06.300: DEBUG/KeyguardViewMediator(58): pokeWakelock(5000)
05-10 00:38:06.651: INFO/ARMAssembler(58): generated scanline__00000077:03545404_00000004_00000000 [ 47 ipp] (67 ins) at [0x3724c8:0x3725d4] in 7266287 ns
05-10 00:38:06.720: INFO/ARMAssembler(58): generated scanline__00000177:03515104_00001001_00000000 [ 91 ipp] (114 ins) at [0x371380:0x371548] in 1486222 ns
05-10 00:38:30.430: DEBUG/AndroidRuntime(294): Shutting down VM
05-10 00:38:30.430: WARN/dalvikvm(294): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
05-10 00:38:30.752: ERROR/AndroidRuntime(294): FATAL EXCEPTION: main
05-10 00:38:30.752: ERROR/AndroidRuntime(294): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.hellowebview/com.example.hellowebview.HelloWebView}: java.lang.NullPointerException
05-10 00:38:30.752: ERROR/AndroidRuntime(294): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
05-10 00:38:30.752: ERROR/AndroidRuntime(294): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
05-10 00:38:30.752: ERROR/AndroidRuntime(294): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
05-10 00:38:30.752: ERROR/AndroidRuntime(294): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
05-10 00:38:30.752: ERROR/AndroidRuntime(294): at android.os.Handler.dispatchMessage(Handler.java:99)
05-10 00:38:30.752: ERROR/AndroidRuntime(294): at android.os.Looper.loop(Looper.java:123)
05-10 00:38:30.752: ERROR/AndroidRuntime(294): at android.app.ActivityThread.main(ActivityThread.java:4627)
05-10 00:38:30.752: ERROR/AndroidRuntime(294): at java.lang.reflect.Method.invokeNative(Native Method)
05-10 00:38:30.752: ERROR/AndroidRuntime(294): at java.lang.reflect.Method.invoke(Method.java:521)
05-10 00:38:30.752: ERROR/AndroidRuntime(294): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-10 00:38:30.752: ERROR/AndroidRuntime(294): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-10 00:38:30.752: ERROR/AndroidRuntime(294): at dalvik.system.NativeStart.main(Native Method)
05-10 00:38:30.752: ERROR/AndroidRuntime(294): Caused by: java.lang.NullPointerException
05-10 00:38:30.752: ERROR/AndroidRuntime(294): at com.example.hellowebview.HelloWebView.onCreate(HelloWebView.java:51)
05-10 00:38:30.752: ERROR/AndroidRuntime(294): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-10 00:38:30.752: ERROR/AndroidRuntime(294): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
05-10 00:38:30.752: ERROR/AndroidRuntime(294): ... 11 more
Got it. For some reason the order in which the permission is set matters a lot. I changed the order of my permission setting in manifest file and it worked. Here's the modified manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.hellowebview"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".HelloWebView"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I am not sure what is the significance of this but would appreciate if anyone could elaborate.
Got it. For some reason the order in which the permission is set matters a lot. I changed the order of my permission setting in manifest file and it worked. Here's the modified manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.hellowebview"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".HelloWebView"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
mWebView = (WebView) findViewById(R.id.webview);
WebSettings setting =mWebView.getSettings();
mWebView.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return true;
}
mWebView.loadUrl("http://www.google.com");
Use this code .shouldOverrideUrlLoading() not use compulsary.use this code and please reply me this code work or not
Your code looks fine. I would make sure internet is working correctly on the emulator by browsing a few pages on the Android Browser. I have had problems before where the emulator would lose network access.

Categories

Resources