Android in-app purchase fails in my adapter - android

I have a list which has a buy button and on click of this button I would like to make an in-app purchase.
I have created an interface and also a function in my fragment but I am getting following error.
05-11 11:02:03.224: E/AndroidRuntime(2999): FATAL EXCEPTION: main
05-11 11:02:03.224: E/AndroidRuntime(2999): java.lang.ClassCastException: com.chinese.flashcard.ShopActivity cannot be cast to com.chinese.flashcard.TestAdapter$IABHelperProvider
05-11 11:02:03.224: E/AndroidRuntime(2999): at com.chinese.flashcard.TestAdapter.getView(TestAdapter.java:82)
05-11 11:02:03.224: E/AndroidRuntime(2999): at android.widget.AbsListView.obtainView(AbsListView.java:2177)
05-11 11:02:03.224: E/AndroidRuntime(2999): at android.widget.ListView.makeAndAddView(ListView.java:1840)
05-11 11:02:03.224: E/AndroidRuntime(2999): at android.widget.ListView.fillDown(ListView.java:675)
05-11 11:02:03.224: E/AndroidRuntime(2999): at android.widget.ListView.fillFromTop(ListView.java:736)
05-11 11:02:03.224: E/AndroidRuntime(2999): at android.widget.ListView.layoutChildren(ListView.java:1655)
05-11 11:02:03.224: E/AndroidRuntime(2999): at android.widget.AbsListView.onLayout(AbsListView.java:2012)
05-11 11:02:03.224: E/AndroidRuntime(2999): at android.view.View.layout(View.java:14289)
05-11 11:02:03.224: E/AndroidRuntime(2999): at android.view.ViewGroup.layout(ViewGroup.java:4562)
05-11 11:02:03.224: E/AndroidRuntime(2999): at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1076)

Related

android app using GCM crash after running

I am trying to create an app using GCM tech to push notifications, but the app crashes after running.
here is my logfile ..I can't find the mistake:
05-11 20:04:55.758: I/dalvikvm(20069): DexOpt: access denied from Lcom/google/android/gms/common/GooglePlayServicesUtil; to field Landroid/app/Notification;.extras
05-11 20:04:55.758: W/dalvikvm(20069): VFY: unable to resolve instance field 12
05-11 20:04:55.758: D/dalvikvm(20069): VFY: replacing opcode 0x54 at 0x00b3
05-11 20:04:55.758: E/dalvikvm(20069): Could not find class 'android.app.AppOpsManager', referenced from method com.google.android.gms.common.GooglePlayServicesUtil.zza
05-11 20:04:55.758: W/dalvikvm(20069): VFY: unable to resolve check-cast 29 (Landroid/app/AppOpsManager;) in Lcom/google/android/gms/common/GooglePlayServicesUtil;
05-11 20:04:55.758: D/dalvikvm(20069): VFY: replacing opcode 0x1f at 0x000e
05-11 20:04:55.758: I/dalvikvm(20069): Could not find method android.content.pm.PackageManager.getPackageInstaller, referenced from method com.google.android.gms.common.GooglePlayServicesUtil.zzh
05-11 20:04:55.758: W/dalvikvm(20069): VFY: unable to resolve virtual method 534: Landroid/content/pm/PackageManager;.getPackageInstaller ()Landroid/content/pm/PackageInstaller;
05-11 20:04:55.758: D/dalvikvm(20069): VFY: replacing opcode 0x6e at 0x000b
05-11 20:04:55.793: D/AndroidRuntime(20069): Shutting down VM
05-11 20:04:55.793: W/dalvikvm(20069): threadid=1: thread exiting with uncaught exception (group=0x4108f2a0)
05-11 20:04:55.803: E/AndroidRuntime(20069): FATAL EXCEPTION: main
05-11 20:04:55.803: E/AndroidRuntime(20069): java.lang.RuntimeException: Unable to resume activity {com.prgguru.example/com.prgguru.example.MainActivity}: java.lang.IllegalStateException: A required meta-data tag in your app's AndroidManifest.xml does not exist. 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" />
05-11 20:04:55.803: E/AndroidRuntime(20069): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2639)
05-11 20:04:55.803: E/AndroidRuntime(20069): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2667)
05-11 20:04:55.803: E/AndroidRuntime(20069): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2140)
05-11 20:04:55.803: E/AndroidRuntime(20069): at android.app.ActivityThread.access$700(ActivityThread.java:140)
05-11 20:04:55.803: E/AndroidRuntime(20069): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237)
05-11 20:04:55.803: E/AndroidRuntime(20069): at android.os.Handler.dispatchMessage(Handler.java:99)
05-11 20:04:55.803: E/AndroidRuntime(20069): at android.os.Looper.loop(Looper.java:137)
05-11 20:04:55.803: E/AndroidRuntime(20069): at android.app.ActivityThread.main(ActivityThread.java:4921)
05-11 20:04:55.803: E/AndroidRuntime(20069): at java.lang.reflect.Method.invokeNative(Native Method)
05-11 20:04:55.803: E/AndroidRuntime(20069): at java.lang.reflect.Method.invoke(Method.java:511)
05-11 20:04:55.803: E/AndroidRuntime(20069): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
05-11 20:04:55.803: E/AndroidRuntime(20069): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
05-11 20:04:55.803: E/AndroidRuntime(20069): at dalvik.system.NativeStart.main(Native Method)
05-11 20:04:55.803: E/AndroidRuntime(20069): Caused by: java.lang.IllegalStateException: A required meta-data tag in your app's AndroidManifest.xml does not exist. 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" />
05-11 20:04:55.803: E/AndroidRuntime(20069): at com.google.android.gms.common.GooglePlayServicesUtil.zzO(Unknown Source)
05-11 20:04:55.803: E/AndroidRuntime(20069): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
05-11 20:04:55.803: E/AndroidRuntime(20069): at com.prgguru.example.MainActivity.checkPlayServices(MainActivity.java:206)
05-11 20:04:55.803: E/AndroidRuntime(20069): at com.prgguru.example.MainActivity.onResume(MainActivity.java:235)
05-11 20:04:55.803: E/AndroidRuntime(20069): at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1199)
05-11 20:04:55.803: E/AndroidRuntime(20069): at android.app.Activity.performResume(Activity.java:5280)
05-11 20:04:55.803: E/AndroidRuntime(20069): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2629)
05-11 20:04:55.803: E/AndroidRuntime(20069): ... 12 more
05-11 20:04:55.838: D/dalvikvm(20069): GC_CONCURRENT freed 218K, 14% free 9628K/11143K, paused 33ms+3ms, total 77ms
05-11 20:04:55.838: D/dalvikvm(20069): WAIT_FOR_CONCURRENT_GC blocked 33ms
05-11 20:05:11.633: I/Process(20069): Sending signal. PID: 20069 SIG: 9
whats wrong?!
you should add this lines in inside the tag.
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
Make sure google-play-service_lib library added or not to your project.

android, delete multiple rows in sqlite

I need to delete multiple rows from my database table.
This is my code for deletion
String[] paragraph;
.....
//here you can to put various strings within it (1 or more)
.....
db.delete(mytablename,"Paragraph = ?",paragraphs);
It works with 1 string, but it doesn't work with more strings.
Can someone help me, please?
Here there is the error shown by LogCat:
05-11 11:03:01.400: E/AndroidRuntime(767): FATAL EXCEPTION: main
05-11 11:03:01.400: E/AndroidRuntime(767): android.database.sqlite.SQLiteException: bind or column index out of range: handle 0x377500
05-11 11:03:01.400: E/AndroidRuntime(767): at android.database.sqlite.SQLiteProgram.native_bind_string(Native Method)
05-11 11:03:01.400: E/AndroidRuntime(767): at android.database.sqlite.SQLiteProgram.bindString(SQLiteProgram.java:241)
05-11 11:03:01.400: E/AndroidRuntime(767): at android.database.DatabaseUtils.bindObjectToProgram(DatabaseUtils.java:191)
05-11 11:03:01.400: E/AndroidRuntime(767): at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1769)
05-11 11:03:01.400: E/AndroidRuntime(767): at it.tirocinio.Segnalibro$3$3.onClick(Segnalibro.java:196)
05-11 11:03:01.400: E/AndroidRuntime(767): at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:158)
05-11 11:03:01.400: E/AndroidRuntime(767): at android.os.Handler.dispatchMessage(Handler.java:99)
05-11 11:03:01.400: E/AndroidRuntime(767): at android.os.Looper.loop(Looper.java:123)
05-11 11:03:01.400: E/AndroidRuntime(767): at android.app.ActivityThread.main(ActivityThread.java:4627)
05-11 11:03:01.400: E/AndroidRuntime(767): at java.lang.reflect.Method.invokeNative(Native Method)
05-11 11:03:01.400: E/AndroidRuntime(767): at java.lang.reflect.Method.invoke(Method.java:521)
05-11 11:03:01.400: E/AndroidRuntime(767): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-11 11:03:01.400: E/AndroidRuntime(767): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-11 11:03:01.400: E/AndroidRuntime(767): at dalvik.system.NativeStart.main(Native Method)
use this way:
for(int i = 0 ; i < paragraphs.lenght;i++)
{
db.delete(mytablename,"Paragraph ='"+paragraphs[i]+"'",null);
}

run time error in android activity has been stopped [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How do I fix android.os.NetworkOnMainThreadException?
I just built a demo application through this tutorial and when I run the application I get the following error in log cat and the main application is stopped. Does anyone know why I am getting this error?
05-11 15:52:06.492: E/AndroidRuntime(584): FATAL EXCEPTION: main
05-11 15:52:06.492: E/AndroidRuntime(584): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.androidhive.jsonparsing/com.androidhive.jsonparsing.AndroidJSONParsingActivity}: android.os.NetworkOnMainThreadException
05-11 15:52:06.492: E/AndroidRuntime(584): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
05-11 15:52:06.492: E/AndroidRuntime(584): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
05-11 15:52:06.492: E/AndroidRuntime(584): at android.app.ActivityThread.access$600(ActivityThread.java:123)
05-11 15:52:06.492: E/AndroidRuntime(584): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
05-11 15:52:06.492: E/AndroidRuntime(584): at android.os.Handler.dispatchMessage(Handler.java:99)
05-11 15:52:06.492: E/AndroidRuntime(584): at android.os.Looper.loop(Looper.java:137)
05-11 15:52:06.492: E/AndroidRuntime(584): at android.app.ActivityThread.main(ActivityThread.java:4424)
05-11 15:52:06.492: E/AndroidRuntime(584): at java.lang.reflect.Method.invokeNative(Native Method)
05-11 15:52:06.492: E/AndroidRuntime(584): at java.lang.reflect.Method.invoke(Method.java:511)
05-11 15:52:06.492: E/AndroidRuntime(584): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-11 15:52:06.492: E/AndroidRuntime(584): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
05-11 15:52:06.492: E/AndroidRuntime(584): at dalvik.system.NativeStart.main(Native Method)
05-11 15:52:06.492: E/AndroidRuntime(584): Caused by: android.os.NetworkOnMainThreadException
05-11 15:52:06.492: E/AndroidRuntime(584): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1099)
05-11 15:52:06.492: E/AndroidRuntime(584): at java.net.InetAddress.lookupHostByName(InetAddress.java:391)
05-11 15:52:06.492: E/AndroidRuntime(584): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:242)
05-11 15:52:06.492: E/AndroidRuntime(584): at java.net.InetAddress.getAllByName(InetAddress.java:220)
05-11 15:52:06.492: E/AndroidRuntime(584): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:137)
05-11 15:52:06.492: E/AndroidRuntime(584): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
05-11 15:52:06.492: E/AndroidRuntime(584): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
05-11 15:52:06.492: E/AndroidRuntime(584): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
05-11 15:52:06.492: E/AndroidRuntime(584): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
05-11 15:52:06.492: E/AndroidRuntime(584): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
05-11 15:52:06.492: E/AndroidRuntime(584): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
05-11 15:52:06.492: E/AndroidRuntime(584): at com.androidhive.jsonparsing.JSONParser.getJSONFromUrl(JSONParser.java:38)
05-11 15:52:06.492: E/AndroidRuntime(584): at com.androidhive.jsonparsing.AndroidJSONParsingActivity.onCreate(AndroidJSONParsingActivity.java:54)
05-11 15:52:06.492: E/AndroidRuntime(584): at android.app.Activity.performCreate(Activity.java:4465)
05-11 15:52:06.492: E/AndroidRuntime(584): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
05-11 15:52:06.492: E/AndroidRuntime(584): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
05-11 15:52:06.492: E/AndroidRuntime(584): ... 11 more
Rebuild the same for android target before 3.0 (such as for 2.1). Androids before 3.0 don't check if you're making network connections on main thread.
After it works as a quick fix then move your networking away from the main thread.
see: http://developer.android.com/reference/android/os/NetworkOnMainThreadException.html

Getting ClassNotFound

i have this messages from LogCat
dalvikvm(526): Could not find class 'com.temp.pt.database.DBHelper',
referenced from method com.temp.pt.database.DBUtils.getDBHelper
and after this i have this
05-11 21:46:25.305: E/AndroidRuntime(526): FATAL EXCEPTION: main
05-11 21:46:25.305: E/AndroidRuntime(526): java.lang.NoClassDefFoundError: com.temp.pt.database.DBHelper
05-11 21:46:25.305: E/AndroidRuntime(526): at com.temp.pt.database.DBUtils.getDBHelper(DBUtils.java:20)
05-11 21:46:25.305: E/AndroidRuntime(526): at com.temp.pt.CategoriesFragment$CategoryAsyncLoader.<init>(CategoriesFragment.java:169)
05-11 21:46:25.305: E/AndroidRuntime(526): at com.temp.pt.CategoriesFragment.onCreateLoader(CategoriesFragment.java:76)
05-11 21:46:25.305: E/AndroidRuntime(526): at android.support.v4.app.LoaderManagerImpl.createLoader(LoaderManager.java:486)
05-11 21:46:25.305: E/AndroidRuntime(526): at android.support.v4.app.LoaderManagerImpl.createAndInstallLoader(LoaderManager.java:495)
05-11 21:46:25.305: E/AndroidRuntime(526): at android.support.v4.app.LoaderManagerImpl.initLoader(LoaderManager.java:549)
05-11 21:46:25.305: E/AndroidRuntime(526): at com.temp.pt.CategoriesFragment.onActivityCreated(CategoriesFragment.java:45)
05-11 21:46:25.305: E/AndroidRuntime(526): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:891)
05-11 21:46:25.305: E/AndroidRuntime(526): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1080)
05-11 21:46:25.305: E/AndroidRuntime(526): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1062)
05-11 21:46:25.305: E/AndroidRuntime(526): at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:1810)
05-11 21:46:25.305: E/AndroidRuntime(526): at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:501)
05-11 21:46:25.305: E/AndroidRuntime(526): at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1133)
05-11 21:46:25.305: E/AndroidRuntime(526): at android.app.Activity.performStart(Activity.java:4475)
05-11 21:46:25.305: E/AndroidRuntime(526): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1929)
05-11 21:46:25.305: E/AndroidRuntime(526): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
05-11 21:46:25.305: E/AndroidRuntime(526): at android.app.ActivityThread.access$600(ActivityThread.java:123)
05-11 21:46:25.305: E/AndroidRuntime(526): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
05-11 21:46:25.305: E/AndroidRuntime(526): at android.os.Handler.dispatchMessage(Handler.java:99)
05-11 21:46:25.305: E/AndroidRuntime(526): at android.os.Looper.loop(Looper.java:137)
05-11 21:46:25.305: E/AndroidRuntime(526): at android.app.ActivityThread.main(ActivityThread.java:4424)
05-11 21:46:25.305: E/AndroidRuntime(526): at java.lang.reflect.Method.invokeNative(Native Method)
05-11 21:46:25.305: E/AndroidRuntime(526): at java.lang.reflect.Method.invoke(Method.java:511)
05-11 21:46:25.305: E/AndroidRuntime(526): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-11 21:46:25.305: E/AndroidRuntime(526): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
05-11 21:46:25.305: E/AndroidRuntime(526): at dalvik.system.NativeStart.main(Native Method)
note i have define the class and the app compiles without error but crash at runtime . any suggestion , ,solution for this problem ?

Unable to download .jpg image and set into imageview using asynctask

I have a problem. I can't seem to download a .jpg image from a URL source and then set it into a imageview which is inside a listview. It gives me the error "NullPointerException". I am currently using the ImageDownloader class from here.
This are the lines of code where i download the image files:
onCreate()...
for (int i = 0; i < listData.size(); i++) {
imageISBN = listData.get(i).get("coverImage");
String isbnURL = "http://lib.syndetics.com/index.aspx?isbn=" + imageISBN +
"/SC.GIF&client=tpoly&type=xw12";
ImageView iv = (ImageView) findViewById(R.id.cover_image);
imageDownloader.download(isbnURL,iv);
}
I'm thinking that it maybe due to my setContentView(R.layout.list) that's producing the error since it is just a listview and the imageview link is in another xml file.
Below is the LogCat:
05-11 09:26:58.063: ERROR/AndroidRuntime(305): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.TPLibrary/com.TPLibrary.Search.SearchResults}: java.lang.NullPointerException
05-11 09:26:58.063: ERROR/AndroidRuntime(305): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
05-11 09:26:58.063: ERROR/AndroidRuntime(305): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
05-11 09:26:58.063: ERROR/AndroidRuntime(305): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
05-11 09:26:58.063: ERROR/AndroidRuntime(305): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
05-11 09:26:58.063: ERROR/AndroidRuntime(305): at android.os.Handler.dispatchMessage(Handler.java:99)
05-11 09:26:58.063: ERROR/AndroidRuntime(305): at android.os.Looper.loop(Looper.java:123)
05-11 09:26:58.063: ERROR/AndroidRuntime(305): at android.app.ActivityThread.main(ActivityThread.java:4627)
05-11 09:26:58.063: ERROR/AndroidRuntime(305): at java.lang.reflect.Method.invokeNative(Native Method)
05-11 09:26:58.063: ERROR/AndroidRuntime(305): at java.lang.reflect.Method.invoke(Method.java:521)
05-11 09:26:58.063: ERROR/AndroidRuntime(305): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-11 09:26:58.063: ERROR/AndroidRuntime(305): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-11 09:26:58.063: ERROR/AndroidRuntime(305): at dalvik.system.NativeStart.main(Native Method)
05-11 09:26:58.063: ERROR/AndroidRuntime(305): Caused by: java.lang.NullPointerException
05-11 09:26:58.063: ERROR/AndroidRuntime(305): at com.TPLibrary.Search.ImageDownloader.forceDownload(ImageDownloader.java:80)
05-11 09:26:58.063: ERROR/AndroidRuntime(305): at com.TPLibrary.Search.ImageDownloader.download(ImageDownloader.java:49)
05-11 09:26:58.063: ERROR/AndroidRuntime(305): at com.TPLibrary.Search.SearchResults.onCreate(SearchResults.java:185)
05-11 09:26:58.063: ERROR/AndroidRuntime(305): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-11 09:26:58.063: ERROR/AndroidRuntime(305): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
05-11 09:26:58.063: ERROR/AndroidRuntime(305): ... 11 more
So guys, any ideas? Could it be that i'm using the ImageDownloader class wrongly?
In ImageDownloader class, the mode is assigned to NO_ASYNC_TASK:
public enum Mode { NO_ASYNC_TASK, NO_DOWNLOADED_DRAWABLE, CORRECT }
private Mode mode = Mode.NO_ASYNC_TASK;
Your intention was to download the image. So try setting the mode variable to NO_DOWNLOADED_DRAWABLE.

Categories

Resources