these are my codes to open GPS
LocationManager locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
locationManager.setTestProviderEnabled("gps", true);
and the permission in my xml
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION"/>
but the apps crashed.
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): java.lang.SecurityException: Requires ACCESS_MOCK_LOCATION secure setting
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at android.os.Parcel.readException(Parcel.java:1218)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at android.os.Parcel.readException(Parcel.java:1206)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at android.location.ILocationManager$Stub$Proxy.setTestProviderEnabled(ILocationManager.java:952)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at android.location.LocationManager.setTestProviderEnabled(LocationManager.java:1054)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at com.hisoft.battery.MainActivity.connGPS(MainActivity.java:118)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at com.hisoft.battery.MainActivity.access$2(MainActivity.java:114)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at com.hisoft.battery.MainActivity$2.onClick(MainActivity.java:62)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at android.view.View.performClick(View.java:2364)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at android.view.View.onTouchEvent(View.java:4179)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at android.widget.TextView.onTouchEvent(TextView.java:6607)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at android.view.View.dispatchTouchEvent(View.java:3709)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:883)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:883)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:883)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:883)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:883)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at android.app.Activity.dispatchTouchEvent(Activity.java:2061)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at android.os.Handler.dispatchMessage(Handler.java:99)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at android.os.Looper.loop(Looper.java:123)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at android.app.ActivityThread.main(ActivityThread.java:4363)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at java.lang.reflect.Method.invokeNative(Native Method)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at java.lang.reflect.Method.invoke(Method.java:521)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
01-07 10:41:35.104: ERROR/AndroidRuntime(1823): at dalvik.system.NativeStart.main(Native Method)
who knows why?
Just guessing here: Go to Settings > Applications > Development > Allow mock locations, and make sure that it is checked.
Related
This question already has answers here:
After Google Play Service update to version 13 I got an error
(8 answers)
Closed 8 years ago.
Hello i am traying to follow this tutorial
http://androidresearch.wordpress.com/2013/09/29/google-maps-api-v2-android-tutorial/
and i downloaded the source code but i cant get it run
this my debug logcat when i run the applicatino on the adv
01-07 19:12:44.086: I/dalvikvm(630): threadid=3: reacting to signal 3
01-07 19:12:44.106: I/dalvikvm(630): Wrote stack traces to '/data/anr/traces.txt'
01-07 19:12:51.036: I/Process(630): Sending signal. PID: 630 SIG: 9
01-07 19:15:28.196: I/dalvikvm(678): threadid=3: reacting to signal 3
01-07 19:15:28.296: I/dalvikvm(678): Wrote stack traces to '/data/anr/traces.txt'
01-07 19:15:28.466: D/AndroidRuntime(678): Shutting down VM
01-07 19:15:28.466: W/dalvikvm(678): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
01-07 19:15:28.486: E/AndroidRuntime(678): FATAL EXCEPTION: main
01-07 19:15:28.486: E/AndroidRuntime(678): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.mapsv2/com.example.mapsv2.MainActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class fragment
01-07 19:15:28.486: E/AndroidRuntime(678): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
01-07 19:15:28.486: E/AndroidRuntime(678): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
01-07 19:15:28.486: E/AndroidRuntime(678): at android.app.ActivityThread.access$600(ActivityThread.java:123)
01-07 19:15:28.486: E/AndroidRuntime(678): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
01-07 19:15:28.486: E/AndroidRuntime(678): at android.os.Handler.dispatchMessage(Handler.java:99)
01-07 19:15:28.486: E/AndroidRuntime(678): at android.os.Looper.loop(Looper.java:137)
01-07 19:15:28.486: E/AndroidRuntime(678): at android.app.ActivityThread.main(ActivityThread.java:4424)
01-07 19:15:28.486: E/AndroidRuntime(678): at java.lang.reflect.Method.invokeNative(Native Method)
01-07 19:15:28.486: E/AndroidRuntime(678): at java.lang.reflect.Method.invoke(Method.java:511)
01-07 19:15:28.486: E/AndroidRuntime(678): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
01-07 19:15:28.486: E/AndroidRuntime(678): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
01-07 19:15:28.486: E/AndroidRuntime(678): at dalvik.system.NativeStart.main(Native Method)
01-07 19:15:28.486: E/AndroidRuntime(678): Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class fragment
01-07 19:15:28.486: E/AndroidRuntime(678): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)
01-07 19:15:28.486: E/AndroidRuntime(678): at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
01-07 19:15:28.486: E/AndroidRuntime(678): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
01-07 19:15:28.486: E/AndroidRuntime(678): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
01-07 19:15:28.486: E/AndroidRuntime(678): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
01-07 19:15:28.486: E/AndroidRuntime(678): at android.app.Activity.setContentView(Activity.java:1835)
01-07 19:15:28.486: E/AndroidRuntime(678): at com.example.mapsv2.MainActivity.onCreate(MainActivity.java:13)
01-07 19:15:28.486: E/AndroidRuntime(678): at android.app.Activity.performCreate(Activity.java:4465)
01-07 19:15:28.486: E/AndroidRuntime(678): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
01-07 19:15:28.486: E/AndroidRuntime(678): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
01-07 19:15:28.486: E/AndroidRuntime(678): ... 11 more
01-07 19:15:28.486: E/AndroidRuntime(678): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 4030500 but found 0. You must have the following declaration within the <application> element: <meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
01-07 19:15:28.486: E/AndroidRuntime(678): at com.google.android.gms.common.GooglePlayServicesUtil.n(Unknown Source)
01-07 19:15:28.486: E/AndroidRuntime(678): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
01-07 19:15:28.486: E/AndroidRuntime(678): at com.google.android.gms.maps.internal.q.v(Unknown Source)
01-07 19:15:28.486: E/AndroidRuntime(678): at com.google.android.gms.maps.internal.q.u(Unknown Source)
01-07 19:15:28.486: E/AndroidRuntime(678): at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
01-07 19:15:28.486: E/AndroidRuntime(678): at com.google.android.gms.maps.SupportMapFragment$b.cE(Unknown Source)
01-07 19:15:28.486: E/AndroidRuntime(678): at com.google.android.gms.maps.SupportMapFragment$b.a(Unknown Source)
01-07 19:15:28.486: E/AndroidRuntime(678): at com.google.android.gms.dynamic.a.a(Unknown Source)
01-07 19:15:28.486: E/AndroidRuntime(678): at com.google.android.gms.dynamic.a.onInflate(Unknown Source)
01-07 19:15:28.486: E/AndroidRuntime(678): at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
01-07 19:15:28.486: E/AndroidRuntime(678): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:284)
01-07 19:15:28.486: E/AndroidRuntime(678): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:669)
01-07 19:15:28.486: E/AndroidRuntime(678): ... 20 more
01-07 19:15:28.706: I/dalvikvm(678): threadid=3: reacting to signal 3
01-07 19:15:28.726: I/dalvikvm(678): Wrote stack traces to '/data/anr/traces.txt'
01-07 19:15:29.106: I/dalvikvm(678): threadid=3: reacting to signal 3
01-07 19:15:29.126: I/dalvikvm(678): Wrote stack traces to '/data/anr/traces.txt'
01-07 19:15:36.495: I/Process(678): Sending signal. PID: 678 SIG: 9
and the xml code is here
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mapsv2"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<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" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyCyR3kVxyrriZlavRfsly-lBYo8Pl4VMkM" />
<activity
android:name="com.example.mapsv2.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>
</application>
</manifest>
It's good habit to read error message first:
E/AndroidRuntime(678): Caused by: java.lang.IllegalStateException: The
meta-data tag in your app's AndroidManifest.xml does not have the
right value. Expected 4030500 but found 0. You must have the
following declaration within the element:
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
so add this to your manifest.
What can I do when I get an Exception but can't understand where to looking for
I mean I know it's in my NewHomeTabActivity, but where should I start searching. I try to insert some logs line and break point but still can't resolve the root cause
01-07 13:39:33.133: W/dalvikvm(12350): threadid=1: thread exiting with uncaught exception (group=0x40c471f8)
01-07 13:39:33.133: W/System.err(12350): java.lang.IllegalStateException: Could not find a method onTabClicked(View) in the activity class att.uc.ui.screen.NewHomeTabActivity for onClick handler on view class android.widget.RelativeLayout with id 'tab_dialer'
01-07 13:39:33.138: W/System.err(12350): at android.view.View$1.onClick(View.java:3085)
01-07 13:39:33.143: W/System.err(12350): at android.view.View.performClick(View.java:3620)
01-07 13:39:33.143: W/System.err(12350): at android.view.View$PerformClick.run(View.java:14292)
01-07 13:39:33.143: W/System.err(12350): at android.os.Handler.handleCallback(Handler.java:605)
01-07 13:39:33.148: W/System.err(12350): at android.os.Handler.dispatchMessage(Handler.java:92)
01-07 13:39:33.148: W/System.err(12350): at android.os.Looper.loop(Looper.java:137)
01-07 13:39:33.148: W/System.err(12350): at android.app.ActivityThread.main(ActivityThread.java:4507)
01-07 13:39:33.153: W/System.err(12350): at java.lang.reflect.Method.invokeNative(Native Method)
01-07 13:39:33.153: W/System.err(12350): at java.lang.reflect.Method.invoke(Method.java:511)
01-07 13:39:33.153: W/System.err(12350): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:980)
01-07 13:39:33.158: W/System.err(12350): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
01-07 13:39:33.158: W/System.err(12350): at dalvik.system.NativeStart.main(Native Method)
01-07 13:39:33.158: W/System.err(12350): Caused by: java.lang.NoSuchMethodException: onTabClicked [class android.view.View]
01-07 13:39:33.163: W/System.err(12350): at java.lang.Class.getConstructorOrMethod(Class.java:460)
01-07 13:39:33.163: W/System.err(12350): at java.lang.Class.getMethod(Class.java:915)
01-07 13:39:33.168: W/System.err(12350): at android.view.View$1.onClick(View.java:3078)
01-07 13:39:33.173: W/System.err(12350): ... 11 more
Read the stactrace from bottom to up line by line to get the relevant message.
It crashes because it cannot find the method onTabClicked(View) in your activity.
I'm assuming that you have an XML control which is given the onClick property, something like this:
android:onClick="onTabClicked"
If so, then your activity should have a method called onTabClicked(View view) that accepts a parameter of type View, this is mandatory.
Like this:
public void onTabClicked(View view){
}
The log suggest it is a RunTimeException so you cannot find it by putting logs ,
the onTabClicked method you have used (maybe defined in xml file ) is not found at RunTime ,
this could be because you have called a higher sdk version while building against lower sdk version , you can either target higher sdk version or use alternative approach for onclick
similar link can suggest a possible solution Android TabWidget detect click on current tab
My application keeps crashing and i do not know what went wrong. I merely added a new package into the application
The codes below is my logcat output of errors
01-07 07:28:51.824: E/AndroidRuntime(471): FATAL EXCEPTION: main
01-07 07:28:51.824: E/AndroidRuntime(471): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.coverflow/com.coverflow.CoverFlowExample}: java.lang.ClassNotFoundException: com.coverflow.CoverFlowExample in loader dalvik.system.PathClassLoader[/data/app/com.example.coverflow-2.apk]
01-07 07:28:51.824: E/AndroidRuntime(471): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1739)
01-07 07:28:51.824: E/AndroidRuntime(471): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1831)
01-07 07:28:51.824: E/AndroidRuntime(471): at android.app.ActivityThread.access$500(ActivityThread.java:122)
01-07 07:28:51.824: E/AndroidRuntime(471): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1024)
01-07 07:28:51.824: E/AndroidRuntime(471): at android.os.Handler.dispatchMessage(Handler.java:99)
01-07 07:28:51.824: E/AndroidRuntime(471): at android.os.Looper.loop(Looper.java:132)
01-07 07:28:51.824: E/AndroidRuntime(471): at android.app.ActivityThread.main(ActivityThread.java:4123)
01-07 07:28:51.824: E/AndroidRuntime(471): at java.lang.reflect.Method.invokeNative(Native Method)
01-07 07:28:51.824: E/AndroidRuntime(471): at java.lang.reflect.Method.invoke(Method.java:491)
01-07 07:28:51.824: E/AndroidRuntime(471): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
01-07 07:28:51.824: E/AndroidRuntime(471): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
01-07 07:28:51.824: E/AndroidRuntime(471): at dalvik.system.NativeStart.main(Native Method)
01-07 07:28:51.824: E/AndroidRuntime(471): Caused by: java.lang.ClassNotFoundException: com.coverflow.CoverFlowExample in loader dalvik.system.PathClassLoader[/data/app/com.example.coverflow-2.apk]
01-07 07:28:51.824: E/AndroidRuntime(471): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:251)
01-07 07:28:51.824: E/AndroidRuntime(471): at java.lang.ClassLoader.loadClass(ClassLoader.java:540)
01-07 07:28:51.824: E/AndroidRuntime(471): at java.lang.ClassLoader.loadClass(ClassLoader.java:500)
01-07 07:28:51.824: E/AndroidRuntime(471): at android.app.Instrumentation.newActivity(Instrumentation.java:1022)
01-07 07:28:51.824: E/AndroidRuntime(471): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1730)
01-07 07:28:51.824: E/AndroidRuntime(471): ... 11 more
Below is my android manifest file, i added the activity intent
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.coverflow"
android:versionCode="1"
android:versionName="1.0">
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:icon="#drawable/icon"
android:label="#string/app_name"
android:largeHeap="true">
<activity android:name="com.coverflow.CoverFlowExample"
android:configChanges="orientation|keyboardHidden"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.example.userguide"></activity>
</application>
<uses-sdk android:minSdkVersion="13" />
<supports-screens android:anyDensity="true" />
</manifest>
You have provided your package name package="com.example.coverflow" and you are giving you are accessing your activity by this name android:name="com.coverflow.CoverFlowExample" . Here you forget to write example , so your fully qualified name is wrong.
Please change it to this:
android:name="com.example.coverflow.CoverFlowExample"
I am trying to implement search in my android app. I have followed the step as suggested by the tutorials to make search possible. I have implemented search with a button.As soon as I press the button,not always but sometimes my Logcat show this error and application stops.This doesnot happen always but sometimes,I dont know why this happening as if this is an issue than the error should showup always when I click the search button.
01-07 13:32:54.759: E/AndroidRuntime(11826): FATAL EXCEPTION: main
01-07 13:32:54.759: E/AndroidRuntime(11826): java.lang.IllegalStateException: Could not execute method of the activity
01-07 13:32:54.759: E/AndroidRuntime(11826): at android.view.View$1.onClick(View.java:3050)
01-07 13:32:54.759: E/AndroidRuntime(11826): at android.view.View.performClick(View.java:3517)
01-07 13:32:54.759: E/AndroidRuntime(11826): at android.view.View$PerformClick.run(View.java:14155)
01-07 13:32:54.759: E/AndroidRuntime(11826): at android.os.Handler.handleCallback(Handler.java:605)
01-07 13:32:54.759: E/AndroidRuntime(11826): at android.os.Handler.dispatchMessage(Handler.java:92)
01-07 13:32:54.759: E/AndroidRuntime(11826): at android.os.Looper.loop(Looper.java:137)
01-07 13:32:54.759: E/AndroidRuntime(11826): at android.app.ActivityThread.main(ActivityThread.java:4508)
01-07 13:32:54.759: E/AndroidRuntime(11826): at java.lang.reflect.Method.invokeNative(Native Method)
01-07 13:32:54.759: E/AndroidRuntime(11826): at java.lang.reflect.Method.invoke(Method.java:511)
01-07 13:32:54.759: E/AndroidRuntime(11826): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809)
01-07 13:32:54.759: E/AndroidRuntime(11826): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576)
01-07 13:32:54.759: E/AndroidRuntime(11826): at dalvik.system.NativeStart.main(Native Method)
01-07 13:32:54.759: E/AndroidRuntime(11826): Caused by: java.lang.reflect.InvocationTargetException
01-07 13:32:54.759: E/AndroidRuntime(11826): at java.lang.reflect.Method.invokeNative(Native Method)
01-07 13:32:54.759: E/AndroidRuntime(11826): at java.lang.reflect.Method.invoke(Method.java:511)
01-07 13:32:54.759: E/AndroidRuntime(11826): at android.view.View$1.onClick(View.java:3045)
01-07 13:32:54.759: E/AndroidRuntime(11826): ... 11 more
01-07 13:32:54.759: E/AndroidRuntime(11826): Caused by: java.lang.OutOfMemoryError
01-07 13:32:54.759: E/AndroidRuntime(11826): at android.graphics.Bitmap.nativeCreate(Native Method)
01-07 13:32:54.759: E/AndroidRuntime(11826): at android.graphics.Bitmap.createBitmap(Bitmap.java:605)
01-07 13:32:54.759: E/AndroidRuntime(11826): at android.graphics.Bitmap.createBitmap(Bitmap.java:551)
01-07 13:32:54.759: E/AndroidRuntime(11826): at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:437)
01-07 13:32:54.759: E/AndroidRuntime(11826): at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:543)
01-07 13:32:54.759: E/AndroidRuntime(11826): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:518)
01-07 13:32:54.759: E/AndroidRuntime(11826): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:370)
01-07 13:32:54.759: E/AndroidRuntime(11826): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:773)
01-07 13:32:54.759: E/AndroidRuntime(11826): at android.content.res.Resources.loadDrawable(Resources.java:1935)
01-07 13:32:54.759: E/AndroidRuntime(11826): at android.content.res.Resources.getDrawable(Resources.java:664)
01-07 13:32:54.759: E/AndroidRuntime(11826): at android.app.ApplicationPackageManager.getDrawable(ApplicationPackageManager.java:580)
01-07 13:32:54.759: E/AndroidRuntime(11826): at android.content.pm.PackageItemInfo.loadIcon(PackageItemInfo.java:140)
01-07 13:32:54.759: E/AndroidRuntime(11826): at android.app.ApplicationPackageManager.getApplicationIcon(ApplicationPackageManager.java:637)
01-07 13:32:54.759: E/AndroidRuntime(11826): at android.app.SearchDialog.updateSearchAppIcon(SearchDialog.java:438)
01-07 13:32:54.759: E/AndroidRuntime(11826): at android.app.SearchDialog.updateUI(SearchDialog.java:391)
01-07 13:32:54.759: E/AndroidRuntime(11826): at android.app.SearchDialog.show(SearchDialog.java:278)
01-07 13:32:54.759: E/AndroidRuntime(11826): at android.app.SearchDialog.doShow(SearchDialog.java:230)
01-07 13:32:54.759: E/AndroidRuntime(11826): at android.app.SearchDialog.show(SearchDialog.java:212)
01-07 13:32:54.759: E/AndroidRuntime(11826): at android.app.SearchManager.startSearch(SearchManager.java:526)
01-07 13:32:54.759: E/AndroidRuntime(11826): at android.app.SearchManager.startSearch(SearchManager.java:503)
01-07 13:32:54.759: E/AndroidRuntime(11826): at android.app.Activity.startSearch(Activity.java:3055)
01-07 13:32:54.759: E/AndroidRuntime(11826): at android.app.Activity.onSearchRequested(Activity.java:3018)
01-07 13:32:54.759: E/AndroidRuntime(11826): at com.vahzay.android.smstrove.ListMessages.onsearchClick(ListMessages.java:150)
01-07 13:32:54.759: E/AndroidRuntime(11826): ... 14 more
Here is the snippet that cause this error
public void onsearchClick(View v) {
if (v.getId() == R.id.searcher) {
Log.i("search has been clicked", "show");
// this method is used to call the search activity from the
// listmessages activity no intent is used as its need a special
// functionality
onSearchRequested(); // line no 150
}
}
This crash happened due to Out of Memory Exception as given in your log. The search icon is not being loaded properly. For using Bitmaps efficiently take a look at this.
I'm trying to send a sms with chinese characters using SMSManager. It works fine for english and german, but unfortunately not for chinese.
My Log:
01-07 20:23:56.200: W/System.err(15742): java.lang.NullPointerException
01-07 20:23:56.200: W/System.err(15742): at android.os.Parcel.readException(Parcel.java:1266)
01-07 20:23:56.204: W/System.err(15742): at android.os.Parcel.readException(Parcel.java:1248)
01-07 20:23:56.204: W/System.err(15742): at com.android.internal.telephony.ISms$Stub$Proxy.sendText(ISms.java:561)
01-07 20:23:56.204: W/System.err(15742): at android.telephony.SmsManager.sendTextMessage(SmsManager.java:109)
01-07 20:23:56.204: W/System.err(15742): at com.app.myapp.MainActivity.sendSms(MainActivity.java:158)
01-07 20:23:56.204: W/System.err(15742): at com.app.myapp.MainActivity.buttonClick(MainActivity.java:103)
01-07 20:23:56.204: W/System.err(15742): at java.lang.reflect.Method.invokeNative(Native Method)
01-07 20:23:56.204: W/System.err(15742): at java.lang.reflect.Method.invoke(Method.java:521)
01-07 20:23:56.204: W/System.err(15742): at android.view.View$1.onClick(View.java:2067)
01-07 20:23:56.204: W/System.err(15742): at android.view.View.performClick(View.java:2408)
01-07 20:23:56.204: W/System.err(15742): at android.view.View$PerformClick.run(View.java:8818)
01-07 20:23:56.204: W/System.err(15742): at android.os.Handler.handleCallback(Handler.java:587)
01-07 20:23:56.204: W/System.err(15742): at android.os.Handler.dispatchMessage(Handler.java:92)
01-07 20:23:56.204: W/System.err(15742): at android.os.Looper.loop(Looper.java:123)
01-07 20:23:56.204: W/System.err(15742): at android.app.ActivityThread.main(ActivityThread.java:4627)
01-07 20:23:56.208: W/System.err(15742): at java.lang.reflect.Method.invokeNative(Native Method)
01-07 20:23:56.208: W/System.err(15742): at java.lang.reflect.Method.invoke(Method.java:521)
01-07 20:23:56.208: W/System.err(15742): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:871)
01-07 20:23:56.208: W/System.err(15742): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)
01-07 20:23:56.208: W/System.err(15742): at dalvik.system.NativeStart.main(Native Method)
And this is how I send the SMS
SmsManager smsManager = SmsManager.getDefault();
for (int i = 0; i < numbers.size(); i++) {
smsManager.sendTextMessage(numbers.get(i), null,
message, null, null);
}
Any ideas? Thanks in advance.
I had the same problem, I could solved it just limiting the number of characters. In English, 160 characters are allowed. In Chinese, only 70 characters can be used (each character takes more bytes to be represented).
So, to test it, just replace message with message.substring(0, 69) and it will work.
To properly solve the proble, splitted messages must be sent, check:
http://www.programering.com/a/MTM4EjMwATE.html