android 3G permission - android

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

Related

Android Maps V2 App Crashing

I have made an app that uses Google Android Maps API V2 and I have followed every step in the guide provided by Google but it doesn't work unfortunely and it crashes every time I try to start it up. So I'm wondering what is the problem?
MainActivity.java
package com.android.maptest;
import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.MapFragment"/>
Maptest Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.maptest"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="16" />
<permission
android:name="com.android.maptest.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-permission android:name="com.android.maptest.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme"
android:debuggable="true" >
<activity
android:name="com.android.maptest.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="api_key" />
</application>
</manifest>
Logcat
03-12 09:46:13.150: D/AndroidRuntime(1547): Shutting down VM
03-12 09:46:13.150: W/dalvikvm(1547): threadid=1: thread exiting with uncaught exception (group=0x410e22a0)
03-12 09:46:13.155: E/AndroidRuntime(1547): FATAL EXCEPTION: main
03-12 09:46:13.155: E/AndroidRuntime(1547): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.maptest/com.android.maptest.MainActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2100)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
03-12 09:46:13.155: E/AndroidRuntime(1547): at
android.app.ActivityThread.access$600(ActivityThread.java:140)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.os.Handler.dispatchMessage(Handler.java:99)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.os.Looper.loop(Looper.java:137)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.app.ActivityThread.main(ActivityThread.java:4898)
03-12 09:46:13.155: E/AndroidRuntime(1547): at java.lang.reflect.Method.invokeNative(Native Method)
03-12 09:46:13.155: E/AndroidRuntime(1547): at java.lang.reflect.Method.invoke(Method.java:511)
03-12 09:46:13.155: E/AndroidRuntime(1547): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
03-12 09:46:13.155: E/AndroidRuntime(1547): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
03-12 09:46:13.155: E/AndroidRuntime(1547): at dalvik.system.NativeStart.main(Native Method)
03-12 09:46:13.155: E/AndroidRuntime(1547): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
03-12 09:46:13.155: E/AndroidRuntime(1547): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:308)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.app.Activity.setContentView(Activity.java:1924)
03-12 09:46:13.155: E/AndroidRuntime(1547): at com.android.maptest.MainActivity.onCreate(MainActivity.java:11)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.app.Activity.performCreate(Activity.java:5206)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
03-12 09:46:13.155: E/AndroidRuntime(1547): ... 11 more
03-12 09:46:13.155: E/AndroidRuntime(1547): Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.android.gms.maps.MapFragment: make sure class name exists, is public, and has an empty constructor that is public
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.app.Fragment.instantiate(Fragment.java:584)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.app.Fragment.instantiate(Fragment.java:552)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.app.Activity.onCreateView(Activity.java:4849)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
03-12 09:46:13.155: E/AndroidRuntime(1547): ... 20 more
03-12 09:46:13.155: E/AndroidRuntime(1547): Caused by: java.lang.ClassNotFoundException: com.google.android.gms.maps.MapFragment
03-12 09:46:13.155: E/AndroidRuntime(1547): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
03-12 09:46:13.155: E/AndroidRuntime(1547): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
03-12 09:46:13.155: E/AndroidRuntime(1547): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
03-12 09:46:13.155: E/AndroidRuntime(1547): at android.app.Fragment.instantiate(Fragment.java:574)
03-12 09:46:13.155: E/AndroidRuntime(1547): ... 23 more
03-12 09:51:21.560: I/Process(1547): Sending signal. PID: 1547 SIG: 9
Here a blog post I wrote on how to integrate Google Maps into you application:
Creating Google Map Application
From your error it look like you did not perform correctly steps 2-3 of the blog guide,
for adding Google Play services library into your application.
If you follow carefully the steps written in the guide you will end up with the end result you can see at the end of the post.
I assumed that you have already get Google Maps Android API v2 key and have Google Play services. If you not have already installed it then please follow below steps to solve this problem_
Step 1. you can found it in Android SDK Manager under Extras tick check box of -Google Play services install it and after complete installation, restart your Eclipse.
Step 2. Add library named_ google-play-services_lib found under the extras folder of your Android SDK setup folder to your Android project_
Path of google service lib_
{Your_Android_SDK_direct}\extras\google\google_play_services\libproject\google-play-services_lib
Ex. Location of this lib on My system_
C:\Program Files\Android\android-sdk\extras\google\google_play_services\libproject\google-play-services_lib
I hope this will solve your ploblem.
For me adding:
import com.google.android.gms.maps.SupportMapFragment;
And changing the xml to
<fragment
android:name="com.google.android.gms.maps.SupportMapFragment"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/header" />
resolved the problem. I hope you resolve it too!
Looks like you didn't add the Google Play Services library to your project.
It's located at {Android SDK}\extras\google\google_play_services
Add it as Android Library Project to Eclipse and then add it to your project.

Android - exception launching project on start after copying a lot of code over from another project

am getting this exception:
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{business.premium/business.premium.Problemio}:
java.lang.ClassNotFoundException: business.premium.Problemio
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
at android.app.ActivityThread.access$600(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: business.premium.Problemio
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
... 11 more
java.lang.ClassNotFoundException: business.premium.Problemio
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
at android.app.ActivityThread.access$600(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
it says that class is not there, but it IS there. I tried to configure things in my project's build path, but not too sure what to tweak there.
And here is how I start my Manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="business.premium"
android:versionCode="1"
android:versionName="1.0" >
<supports-screens android:largeScreens="true" android:normalScreens="true" android:smallScreens="true"/>
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="15"/>
<uses-permission android:name="android.permission.INTERNET" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/CustomTheme"
android:name="MyApplication"
android:debuggable="true">
<activity
android:name=".Problemio"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Any thoughts on how to solve this, or what to look into? Thanks!
Its because you specified the "android:name" attribute in the application node in the manifest file.
Do not use the android:name attribute!
It, misleadingly, does not have anything to do with the name of your app and is actually the name of an extra class to load before loading your application. That's why you are getting the ClassNotFoundException.
Remove it and it should work:
<application
android:icon="#drawable/icon"
android:label="#string/app_name"
android:description="#string/help_text" >
This answer is taken from: java.lang.ClassNotFoundException on working app

Live Wall paper force closes

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"

Error java.lang.ClassNotFoundException in my Activity using Google API in Android

I made a test a program for my University which uses Google maps following a tutorial. I made everything like in tutorial, but my app crashes before even showing anything with message "Unfortunately SocialFoot has stopped". I tried to debug and it seems like it crashes even before entering to onCreate method. This is my code:
package it.univpm.dii.socialfoot;
import com.actionbarsherlock.app.SherlockMapActivity;
import android.os.Bundle;
public class SocialFootActivity extends SherlockMapActivity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
#Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
Logcat:
05-18 19:29:59.343: E/AndroidRuntime(3405): FATAL EXCEPTION: main
05-18 19:29:59.343: E/AndroidRuntime(3405): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{it.univpm.dii.socialfoot/it.univpm.dii.socialfoot.activities.SocialFootActivity}: java.lang.ClassNotFoundException: it.univpm.dii.socialfoot.activities.SocialFootActivity
05-18 19:29:59.343: E/AndroidRuntime(3405): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)
05-18 19:29:59.343: E/AndroidRuntime(3405): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
05-18 19:29:59.343: E/AndroidRuntime(3405): at android.app.ActivityThread.access$600(ActivityThread.java:123)
05-18 19:29:59.343: E/AndroidRuntime(3405): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
05-18 19:29:59.343: E/AndroidRuntime(3405): at android.os.Handler.dispatchMessage(Handler.java:99)
05-18 19:29:59.343: E/AndroidRuntime(3405): at android.os.Looper.loop(Looper.java:137)
05-18 19:29:59.343: E/AndroidRuntime(3405): at android.app.ActivityThread.main(ActivityThread.java:4424)
05-18 19:29:59.343: E/AndroidRuntime(3405): at java.lang.reflect.Method.invokeNative(Native Method)
05-18 19:29:59.343: E/AndroidRuntime(3405): at java.lang.reflect.Method.invoke(Method.java:511)
05-18 19:29:59.343: E/AndroidRuntime(3405): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-18 19:29:59.343: E/AndroidRuntime(3405): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
05-18 19:29:59.343: E/AndroidRuntime(3405): at dalvik.system.NativeStart.main(Native Method)
05-18 19:29:59.343: E/AndroidRuntime(3405): Caused by: java.lang.ClassNotFoundException: it.univpm.dii.socialfoot.activities.SocialFootActivity
05-18 19:29:59.343: E/AndroidRuntime(3405): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
05-18 19:29:59.343: E/AndroidRuntime(3405): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
05-18 19:29:59.343: E/AndroidRuntime(3405): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
05-18 19:29:59.343: E/AndroidRuntime(3405): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
05-18 19:29:59.343: E/AndroidRuntime(3405): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
05-18 19:29:59.343: E/AndroidRuntime(3405): ... 11 more
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="it.univpm.dii.socialfoot"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_GPS" />
<uses-sdk android:minSdkVersion="15" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.Sherlock" >
<uses-library android:name="com.google.android.maps" />
<activity
android:name=".SocialFootActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Layout:
The logs indicate the app is trying to launch it.univpm.dii.socialfoot.activities.SocialFootActivity, but SocialFootActivity is in package it.univpm.dii.socialfoot. If this is happening at the start of your application (since that activity is set as the launch activity), I would try cleaning and rebuilding your project and trying again.

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