1

Hi guys I was trying to do a new activity that extend listActivity, because I wanna do a List of items, but when I launch it with a button it gives me java.lang.UnsatisfiedLinkError. The class and the layout is only inizializated nothing special..but it gives me this error :/ Below You can find my logcat and also my layout and my class. Thank you.

Class that extend ListActivity:

public class AndroidListViewActivity extends ListActivity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_list);

        // storing string resources into Array
        //String[] adobe_products = getResources().getStringArray(R.array.adobe_products);
         String[] adobe_products = {"prova","prova1","prova2"};
        // Binding resources Array to ListAdapter
        //this.setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, R.id.label, adobe_products));

    }
}

Layout (R.layout.activity_list):

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"  
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"   
    android:layout_height="match_parent" 
    android:orientation="vertical"
    android:paddingBottom="0dp"
    android:paddingLeft="0dp"
    android:paddingRight="0dp"
    android:paddingTop="0dp"  
    tools:context="com.example.findmyclients.AndroidListViewActivity">

    <FrameLayout
        android:id="@+id/custom_header_list"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="top"
        android:background="@drawable/header" 
        android:layout_alignParentTop="true">
    </FrameLayout>



</RelativeLayout>

Logcat:

10-23 16:23:46.296: W/dalvikvm(16222): No implementation found for native Ldalvik/system/VMRuntime;.pauseGc:(Ljava/lang/String;)I
10-23 16:23:46.301: E/ActivityThread(16222): Pause GC
10-23 16:23:46.301: E/ActivityThread(16222): java.lang.reflect.InvocationTargetException
10-23 16:23:46.301: E/ActivityThread(16222):    at java.lang.reflect.Method.invokeNative(Native Method)
10-23 16:23:46.301: E/ActivityThread(16222):    at java.lang.reflect.Method.invoke(Method.java:515)
10-23 16:23:46.301: E/ActivityThread(16222):    at android.app.ActivityThread.pauseGC(ActivityThread.java:5525)
10-23 16:23:46.301: E/ActivityThread(16222):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2324)
10-23 16:23:46.301: E/ActivityThread(16222):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471)
10-23 16:23:46.301: E/ActivityThread(16222):    at android.app.ActivityThread.access$900(ActivityThread.java:175)
10-23 16:23:46.301: E/ActivityThread(16222):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
10-23 16:23:46.301: E/ActivityThread(16222):    at android.os.Handler.dispatchMessage(Handler.java:102)
10-23 16:23:46.301: E/ActivityThread(16222):    at android.os.Looper.loop(Looper.java:146)
10-23 16:23:46.301: E/ActivityThread(16222):    at android.app.ActivityThread.main(ActivityThread.java:5602)
10-23 16:23:46.301: E/ActivityThread(16222):    at java.lang.reflect.Method.invokeNative(Native Method)
10-23 16:23:46.301: E/ActivityThread(16222):    at java.lang.reflect.Method.invoke(Method.java:515)
10-23 16:23:46.301: E/ActivityThread(16222):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
10-23 16:23:46.301: E/ActivityThread(16222):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
10-23 16:23:46.301: E/ActivityThread(16222):    at dalvik.system.NativeStart.main(Native Method)
10-23 16:23:46.301: E/ActivityThread(16222): Caused by: java.lang.UnsatisfiedLinkError: Native method not found: dalvik.system.VMRuntime.pauseGc:(Ljava/lang/String;)I
10-23 16:23:46.301: E/ActivityThread(16222):    at dalvik.system.VMRuntime.pauseGc(Native Method)
10-23 16:23:46.301: E/ActivityThread(16222):    ... 15 more
Pierpaolo Ercoli
  • 1,028
  • 2
  • 11
  • 32
  • Instead of using a ListActivity or a ListFragment, a ListView in a layout can be a better choice. – Phantômaxx Oct 23 '14 at 14:37
  • it gives me error if I choice ListView instead of ListActivity @Funkystein – Pierpaolo Ercoli Oct 23 '14 at 14:58
  • 1
    I always use ListViews in Activities and Fragments **without** using ListActivity or ListFragment. It gives me **more freedom**. I.e.: I can use **2 ListViews in a single Fragment**. Of course, you don't have to extend ListView. Extend **Activity** or **Fragment**, depending on which is your envelope. – Phantômaxx Oct 23 '14 at 15:17
  • 1
    veeeery goood now work...I don't know why extending ListActivity it gave me error :/ Thank you again @Funkystein :D you have been so precious for me today – Pierpaolo Ercoli Oct 23 '14 at 15:22
  • I'm happy to know I was helpful. – Phantômaxx Oct 23 '14 at 15:27
  • I added an answer to remove this question fromn the Unanswered Queue. Hopefully, someone else could benefit of this answer too. – Phantômaxx Oct 23 '14 at 15:33
  • 1
    Your actual error message and question title refer to a known issue on some Android devices, now linked as a duplicate. But note the indication there that this probably does not result in a crash. If you can find a *different* trace more related to your code, please edit that into your question and update the title to refer to that actual *resolvable-by-you* problem rather than this minor platform bug - and then it would make sense to re-open your question to address that issue. – Chris Stratton Oct 23 '14 at 17:12

1 Answers1

0

Instead of using a ListActivity or a ListFragment, a ListView in a layout can be a better choice.
This is what I mean:

Here I use a Fragment which will contain a ListView:

public final class FRG_List
extends Fragment
{

    private ClickListener listener;

    /* ------------------------------ Objects ------------------------------- */

    private ListView lvw = null;

    // ...

    @Override
    public final View onCreateView
    (
        final LayoutInflater li, final ViewGroup container,
        final Bundle savedInstanceState
    )
    {
        final View v = li.inflate(R.layout.frg_list, container, false);
        return v;
    }

    // ...

}

This is /res/layout/frg_list.xml (the ListView):

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >
    <ListView
        android:id="@+id/lvwResults"
        android:layout_width="match_parent" 
        android:layout_height="match_parent"
        android:layout_margin="4dp"
    />
    <TextView
        android:id="@+id/txtEmpty"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:textColor="@color/black_tsp_50"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textStyle="bold"
        android:shadowColor="@color/white_tsp_50"
        android:shadowRadius="1"
        android:shadowDx="1"
        android:shadowDy="1"
        android:visibility="gone"
        android:clickable="true"
        android:onClick="clickHandler"
    />
</RelativeLayout>

I'm using a TextView to show a "No data found" message when there is no result from the database.
I manage it in code (I set it visible or gone).

But you can skip it if you don't need it (in which case you could get rid of the RelativeLayout container and assign the xml namespace to the ListView itself, in order to flatten your layout - which is good for performances).

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115