Posting text on a facebook page from an android app - android

I'm working on an android app which integrates with facebook(I'm very new).I could successfully implement the login/logout part.
Now I need my android app to post(text) on a specific page.I'm not sure how to approach this. I tried reading all the similar posts. I used "facebook.request(page_id+/feed , parameters , "POST")" ,this always returned a null pointer exception maybe because the request(feed,parameters,"POST") method is deprecated (code written below).
I tried to follow the facebook sdk tutorial which involved access_tokens and graph apis which further confused me.
I don't even know how to approach this anymore.Please, if someone could guide me it would be a lot helpful and easier for me to go about this.
Thank you.
try{
Tring response = facebook.request("me");
Bundle parameters = new Bundle();
parameters.putString("message", msg);
parameters.putString("description", "test test test");
// parameters.putByteArray("message", msg);
response = facebook.request("me/feed", parameters, "POST");
Log.d("Tests", "got response: " + response);
if (response == null || response.equals("")
|| response.equals("false")) {
Log.v("Error", "Blank response");
}else{
}
} catch (Exception e) {
e.printStackTrace();
}
}
LOGCAT
01-07 20:14:21.330 7830-7835/com.example.kai.gameofapis2 D/dalvikvm﹕ Debugger has detached; object registry had 1 entries
01-07 20:16:21.460 11583-11583/com.example.kai.gameofapis2 V/Zygote﹕ Switching descriptor 33 to /dev/null
01-07 20:16:21.460 11583-11583/com.example.kai.gameofapis2 V/Zygote﹕ Switching descriptor 9 to /dev/null
01-07 20:16:21.470 11583-11583/com.example.kai.gameofapis2 D/dalvikvm﹕ Late-enabling CheckJNI
01-07 20:16:21.710 11583-11583/com.example.kai.gameofapis2 D/ActivityThread﹕ handleBindApplication:com.example.kai.gameofapis2
01-07 20:16:21.720 11583-11583/com.example.kai.gameofapis2 D/ActivityThread﹕ setTargetHeapUtilization:0.75
01-07 20:16:21.720 11583-11583/com.example.kai.gameofapis2 D/ActivityThread﹕ setTargetHeapMinFree:524288
01-07 20:16:22.301 11583-11583/com.example.kai.gameofapis2 I/MainFragment﹕ Logged in...
01-07 20:16:22.471 11583-11583/com.example.kai.gameofapis2 D/libEGL﹕ loaded /system/lib/egl/libEGL_mali.so
01-07 20:16:22.701 11583-11583/com.example.kai.gameofapis2 D/libEGL﹕ loaded /system/lib/egl/libGLESv1_CM_mali.so
01-07 20:16:22.701 11583-11583/com.example.kai.gameofapis2 D/libEGL﹕ loaded /system/lib/egl/libGLESv2_mali.so
01-07 20:16:22.831 11583-11583/com.example.kai.gameofapis2 D/OpenGLRenderer﹕ Enabling debug mode 0
01-07 20:16:22.831 11583-11583/com.example.kai.gameofapis2 I/MainFragment﹕ Logged in...
01-07 20:16:22.951 11583-11583/com.example.kai.gameofapis2 I/Timeline﹕ Timeline: Activity_idle id: android.os.BinderProxy#41d82b18 time:64292484
01-07 20:16:30.539 11583-11583/com.example.kai.gameofapis2 W/System.err﹕ java.lang.NullPointerException
01-07 20:16:30.549 11583-11583/com.example.kai.gameofapis2 W/System.err﹕ at com.example.kai.gameofapis2.MainFragment$2.onClick(MainFragment.java:75)
01-07 20:16:30.549 11583-11583/com.example.kai.gameofapis2 W/System.err﹕ at android.view.View.performClick(View.java:4438)
01-07 20:16:30.549 11583-11583/com.example.kai.gameofapis2 W/System.err﹕ at android.view.View$PerformClick.run(View.java:18439)
01-07 20:16:30.549 11583-11583/com.example.kai.gameofapis2 W/System.err﹕ at android.os.Handler.handleCallback(Handler.java:733)
01-07 20:16:30.549 11583-11583/com.example.kai.gameofapis2 W/System.err﹕ at android.os.Handler.dispatchMessage(Handler.java:95)
01-07 20:16:30.549 11583-11583/com.example.kai.gameofapis2 W/System.err﹕ at android.os.Looper.loop(Looper.java:136)
01-07 20:16:30.549 11583-11583/com.example.kai.gameofapis2 W/System.err﹕ at android.app.ActivityThread.main(ActivityThread.java:5153)
01-07 20:16:30.549 11583-11583/com.example.kai.gameofapis2 W/System.err﹕ at java.lang.reflect.Method.invokeNative(Native Method)
01-07 20:16:30.549 11583-11583/com.example.kai.gameofapis2 W/System.err﹕ at java.lang.reflect.Method.invoke(Method.java:515)
01-07 20:16:30.549 11583-11583/com.example.kai.gameofapis2 W/System.err﹕ at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:796)
01-07 20:16:30.549 11583-11583/com.example.kai.gameofapis2 W/System.err﹕ at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:612)
01-07 20:16:30.549 11583-11583/com.example.kai.gameofapis2 W/System.err﹕ at dalvik.system.NativeStart.main(Native Method)

Related

IllegalStateException when performing LinearLayout.addView(View)

so I am trying to add a view to the layout on buttonclick but it throws IllegalStateException. I am adding this view to a LinearLayout inside of the LinearLayout which is shown when the activity starts.
Here is the log:
06-13 20:05:20.415 12368-12368/com.nttkjwmp.syncc.app V/Zygote﹕ Switching descriptor 9 to /dev/null
06-13 20:05:20.420 12368-12368/com.nttkjwmp.syncc.app D/dalvikvm﹕ Late-enabling CheckJNI
06-13 20:05:20.495 12368-12368/com.nttkjwmp.syncc.app D/ActivityThread﹕ handleBindApplication:com.nttkjwmp.syncc.app
06-13 20:05:20.495 12368-12368/com.nttkjwmp.syncc.app D/ActivityThread﹕ setTargetHeapUtilization:0.75
06-13 20:05:20.495 12368-12368/com.nttkjwmp.syncc.app D/ActivityThread﹕ setTargetHeapMinFree:2097152
06-13 20:05:20.925 12368-12368/com.nttkjwmp.syncc.app D/libEGL﹕ loaded /system/lib/egl/libEGL_mali.so
06-13 20:05:20.930 12368-12368/com.nttkjwmp.syncc.app D/libEGL﹕ loaded /system/lib/egl/libGLESv1_CM_mali.so
06-13 20:05:20.935 12368-12368/com.nttkjwmp.syncc.app D/libEGL﹕ loaded /system/lib/egl/libGLESv2_mali.so
06-13 20:05:20.940 12368-12368/com.nttkjwmp.syncc.app E/﹕ Device driver API match
Device driver API version: 23
User space API version: 23
06-13 20:05:20.940 12368-12368/com.nttkjwmp.syncc.app E/﹕ mali: REVISION=Linux-r3p2-01rel3 BUILD_DATE=Wed Oct 9 21:05:57 KST 2013
06-13 20:05:21.005 12368-12368/com.nttkjwmp.syncc.app D/OpenGLRenderer﹕ Enabling debug mode 0
06-13 20:05:21.415 12368-12368/com.nttkjwmp.syncc.app I/Timeline﹕ Timeline: Activity_idle id: android.os.BinderProxy#41b6cf08 time:2108923
06-13 20:05:27.535 12368-12368/com.nttkjwmp.syncc.app I/Timeline﹕ Timeline: Activity_launch_request id:com.nttkjwmp.syncc.app time:2115041
06-13 20:05:28.185 12368-12368/com.nttkjwmp.syncc.app E/SpannableStringBuilder﹕ SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
06-13 20:05:28.185 12368-12368/com.nttkjwmp.syncc.app E/SpannableStringBuilder﹕ SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
06-13 20:05:28.185 12368-12368/com.nttkjwmp.syncc.app I/Timeline﹕ Timeline: Activity_idle id: android.os.BinderProxy#41dd3b68 time:2115693
06-13 20:05:30.830 12368-12368/com.nttkjwmp.syncc.app D/AndroidRuntime﹕ Shutting down VM
06-13 20:05:30.830 12368-12368/com.nttkjwmp.syncc.app W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x418b4ce0)
06-13 20:05:30.840 12368-12368/com.nttkjwmp.syncc.app E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.nttkjwmp.syncc.app, PID: 12368
java.lang.IllegalStateException: Could not execute method of the activity
at android.view.View$1.onClick(View.java:3830)
at android.view.View.performClick(View.java:4445)
at android.view.View$PerformClick.run(View.java:18446)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5128)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:611)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at android.view.View$1.onClick(View.java:3825)
            at android.view.View.performClick(View.java:4445)
            at android.view.View$PerformClick.run(View.java:18446)
            at android.os.Handler.handleCallback(Handler.java:733)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5128)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:611)
            at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.nttkjwmp.syncc.app.NewEventActivity.addReminder(NewEventActivity.java:104)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at android.view.View$1.onClick(View.java:3825)
            at android.view.View.performClick(View.java:4445)
            at android.view.View$PerformClick.run(View.java:18446)
            at android.os.Handler.handleCallback(Handler.java:733)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5128)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:611)
            at dalvik.system.NativeStart.main(Native Method)
06-13 20:05:32.365 12368-12368/com.nttkjwmp.syncc.app I/Process﹕ Sending signal. PID: 12368 SIG: 9
06-13 20:05:32.470 12740-12740/com.nttkjwmp.syncc.app D/ActivityThread﹕ handleBindApplication:com.nttkjwmp.syncc.app
06-13 20:05:32.475 12740-12740/com.nttkjwmp.syncc.app D/ActivityThread﹕ setTargetHeapUtilization:0.75
06-13 20:05:32.475 12740-12740/com.nttkjwmp.syncc.app D/ActivityThread﹕ setTargetHeapMinFree:2097152
06-13 20:05:32.700 12740-12740/com.nttkjwmp.syncc.app D/libEGL﹕ loaded /system/lib/egl/libEGL_mali.so
06-13 20:05:32.700 12740-12740/com.nttkjwmp.syncc.app D/libEGL﹕ loaded /system/lib/egl/libGLESv1_CM_mali.so
06-13 20:05:32.705 12740-12740/com.nttkjwmp.syncc.app D/libEGL﹕ loaded /system/lib/egl/libGLESv2_mali.so
06-13 20:05:32.710 12740-12740/com.nttkjwmp.syncc.app E/﹕ Device driver API match
Device driver API version: 23
User space API version: 23
06-13 20:05:32.710 12740-12740/com.nttkjwmp.syncc.app E/﹕ mali: REVISION=Linux-r3p2-01rel3 BUILD_DATE=Wed Oct 9 21:05:57 KST 2013
06-13 20:05:32.775 12740-12740/com.nttkjwmp.syncc.app D/OpenGLRenderer﹕ Enabling debug mode 0
06-13 20:05:33.070 12740-12740/com.nttkjwmp.syncc.app I/Timeline﹕ Timeline: Activity_idle id: android.os.BinderProxy#41b72bf8 time:2120575
also here is the onClick method for the button:
public void addReminder(View view){
View reminder=(View)findViewById(R.id.reminder_layout);
reminderContainer.addView(reminder);
reminders.add(reminder);
}
reminderContainer is the LinearLayout which I want to add the view to. It is inside of another LinearLayout.
here is the reminder_layout.xml file:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/reminder_layout"
>
<Spinner
android:id="#+id/reminder_time"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
<Spinner
android:id="#+id/reminder_type"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_action_remove"
/>
</LinearLayout>
So can anyone point out the mistake? What am I missing here?
Thanks in advance!

android crash exception with no root point

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

socialauth android ResourceNotFound

I am implementing socialAuth android in my application. But when i click my share button there is a error:
01-07 19:25:27.308: D/SocialAuthAdapter(4167): Selected provider is facebook
01-07 19:25:27.308: D/SocialAuthAdapter(4167): Loading keys and secrets from configuration
01-07 19:25:27.328: I/SocialAuthConfig(4167): Loading application configuration
01-07 19:25:27.358: I/OAuth2(4167): Determining URL for redirection
01-07 19:25:27.358: I/OAuth2(4167): Redirection to following URL should happen : https://graph.facebook.com/oauth/authorize?client_id=447809015285714&response_type=code&redirect_uri=fbconnect%3A%2F%2Fsuccess&scope=publish_stream,email,user_birthday,user_location
01-07 19:25:27.358: D/SocialAuthAdapter(4167): Loading URL : https://graph.facebook.com/oauth/authorize?client_id=447809015285714&response_type=code&redirect_uri=fbconnect%3A%2F%2Fsuccess&scope=publish_stream,email,user_birthday,user_location&type=user_agent&display=touch
01-07 19:25:27.358: D/SocialAuthAdapter(4167): Callback URI : fbconnect://success
01-07 19:25:27.368: W/ResourceType(4167): No package identifier when getting value for resource number 0x00000000
01-07 19:25:27.368: D/AndroidRuntime(4167): Shutting down VM
01-07 19:25:27.378: W/dalvikvm(4167): threadid=1: thread exiting with uncaught exception (group=0x40a9c210)
01-07 19:25:27.378: E/AndroidRuntime(4167): FATAL EXCEPTION: main
01-07 19:25:27.378: E/AndroidRuntime(4167): android.content.res.Resources$NotFoundException: Resource ID #0x0
01-07 19:25:27.378: E/AndroidRuntime(4167): at android.content.res.Resources.getValue(Resources.java:1023)
More log.
01-07 19:25:27.378: E/AndroidRuntime(4167): at android.content.res.Resources.getDrawable(Resources.java:668)
01-07 19:25:27.378: E/AndroidRuntime(4167): at org.brickred.socialauth.android.SocialAuthDialog.setUpTitle(SocialAuthDialog.java:149)
01-07 19:25:27.378: E/AndroidRuntime(4167): at org.brickred.socialauth.android.SocialAuthDialog.onCreate(SocialAuthDialog.java:123)
01-07 19:25:27.378: E/AndroidRuntime(4167): at android.app.Dialog.dispatchOnCreate(Dialog.java:353)
01-07 19:25:27.378: E/AndroidRuntime(4167): at android.app.Dialog.show(Dialog.java:257)
01-07 19:25:27.378: E/AndroidRuntime(4167): at org.brickred.socialauth.android.SocialAuthAdapter$3$1.run(SocialAuthAdapter.java:372)
01-07 19:25:27.378: E/AndroidRuntime(4167): at android.os.Handler.handleCallback(Handler.java:605)
01-07 19:25:27.378: E/AndroidRuntime(4167): at android.os.Handler.dispatchMessage(Handler.java:92)
01-07 19:25:27.378: E/AndroidRuntime(4167): at android.os.Looper.loop(Looper.java:137)
01-07 19:25:27.378: E/AndroidRuntime(4167): at android.app.ActivityThread.main(ActivityThread.java:4441)
01-07 19:25:27.378: E/AndroidRuntime(4167): at java.lang.reflect.Method.invokeNative(Native Method)
01-07 19:25:27.378: E/AndroidRuntime(4167): at java.lang.reflect.Method.invoke(Method.java:511)
01-07 19:25:27.378: E/AndroidRuntime(4167): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:823)
01-07 19:25:27.378: E/AndroidRuntime(4167): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:590)
01-07 19:25:27.378: E/AndroidRuntime(4167): at dalvik.system.NativeStart.main(Native Method)
And i have no idea why is that happening.
I have followed very carefully after examples.
Please put Icon for facebook,Google, twitter with name facebook.png,foursquare.png,google.png,linkedin.png,myspace.png,twitter.png,yahoo.png int res folder.
Just put on your Image (facebook.png , linkedin.png , twitter.png or many more who your integrate with your app) drawable folder.
This problem occur because on your lib file require icon and if its not here on your package then its shows error.
No package identifier when getting value for resource number 0x00000000
android.content.res.Resources$NotFoundException: Resource ID #0x0
at android.content.res.Resources.getDrawable(Resources.java:668)
at org.brickred.socialauth.android.SocialAuthDialog.setUpTitle(SocialAuthDialog.java:149)
above i m just shown u main error which occur when file is not here on your drawable.

java.lang.illegalStateException during performing Search using Android Search Configration

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.

SMSManager for chinese, Nullpointer

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

Categories

Resources