android java. lang.非法参数异常:未知的URI内容

gmxoilav  于 2023-02-17  发布在  Android
关注(0)|答案(1)|浏览(169)

我试着运行程序代码soundclouddroid https://code.google.com/p/soundclouddroid/source/browse/ 1.2.2.我有另一个问题之前,我解决了Stackoverflow,但现在我有一个,不明白为什么会发生。我的问题是:

java.lang.RuntimeException: Unable to start activity ComponentInfo {es.manu.sd122.soundCloudDroid/es.manu.sd122.soundCloudDroid.CustomTrackListsActivity}: java.lang.IllegalArgumentException: Unknown URI content :/ / is .manu.sd122.provider.soundCloudDroid/tracklists

该程序试图拉Souncloud数据。在Souncloud页面我创建了一个应用程序,我已经获得了客户端ID和客户端密码,我还添加了重定向URI字段,我已经设置为认证:http://es.manu.sd122.provider.soundCloudDroid。该网站添加了http://声云网站。
你能帮帮我吗?谢谢
日志目录:

10-18 09:07:45.839: E/AndroidRuntime(400): FATAL EXCEPTION: main
10-18 09:07:45.839: E/AndroidRuntime(400): java.lang.RuntimeException: Unable to start activity ComponentInfo{es.manu.sd122.soundCloudDroid/es.manu.sd122.soundCloudDroid.CustomTrackListsActivity}: java.lang.IllegalArgumentException: Unknown URI content://es.manu.sd122.provider.soundCloudDroid/tracklists
10-18 09:07:45.839: E/AndroidRuntime(400):  at  android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
10-18 09:07:45.839: E/AndroidRuntime(400):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
10-18 09:07:45.839: E/AndroidRuntime(400):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
10-18 09:07:45.839: E/AndroidRuntime(400):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
10-18 09:07:45.839: E/AndroidRuntime(400):  at android.os.Handler.dispatchMessage(Handler.java:99)
10-18 09:07:45.839: E/AndroidRuntime(400):  at android.os.Looper.loop(Looper.java:123)
10-18 09:07:45.839: E/AndroidRuntime(400):  at android.app.ActivityThread.main(ActivityThread.java:3683)
10-18 09:07:45.839: E/AndroidRuntime(400):  at java.lang.reflect.Method.invokeNative(Native Method)
10-18 09:07:45.839: E/AndroidRuntime(400):  at java.lang.reflect.Method.invoke(Method.java:507)
10-18 09:07:45.839: E/AndroidRuntime(400):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
10-18 09:07:45.839: E/AndroidRuntime(400):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
10-18 09:07:45.839: E/AndroidRuntime(400):  at dalvik.system.NativeStart.main(Native Method)
10-18 09:07:45.839: E/AndroidRuntime(400): Caused by: java.lang.IllegalArgumentException: Unknown URI content://es.manu.sd122.provider.soundCloudDroid/tracklists
10-18 09:07:45.839: E/AndroidRuntime(400):  at es.manu.sd122.soundCloudBase.SoundCloudData.query(SoundCloudData.java:244)
10-18 09:07:45.839: E/AndroidRuntime(400):  at android.content.ContentProvider$Transport.query(ContentProvider.java:187)
10-18 09:07:45.839: E/AndroidRuntime(400):  at android.content.ContentResolver.query(ContentResolver.java:262)
10-18 09:07:45.839: E/AndroidRuntime(400):  at es.manu.sd122.soundCloudDroid.CustomTrackListsActivity.onCreate(CustomTrackListsActivity.java:28)
10-18 09:07:45.839: E/AndroidRuntime(400):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
10-18 09:07:45.839: E/AndroidRuntime(400):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
10-18 09:07:45.839: E/AndroidRuntime(400):  ... 11 more

清单:

<provider android:name="es.manu.sd122.soundCloudBase.SoundCloudData" android:authorities="es.manu.sd122.provider.soundCloudDroid">
        </provider>

声音CloudDroid的数据库

import android.net.Uri;
import android.provider.BaseColumns;

public class DB extends es.manu.sd122.soundCloudBase.DB
{
    protected DB()
    {
        super();
    }

    public static final class TrackLists implements BaseColumns
    {
        // This class cannot be instantiated
        private TrackLists() {}

        public static final String TABLE_NAME = "tracklists";

        /**
         * The content:// style URL for this table
         */
        public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/tracklists");

        /**
         * The MIME type of {@link #CONTENT_URI} providing a directory of entries.
         */
        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/" + PACKAGE + ".tracklists";

        /**
         * The MIME type of a {@link #CONTENT_URI} sub-directory of a single entry.
         */
        public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/" + PACKAGE + ".tracklists";

        public static final String RESOURCE = "resource";

        public static final String TITLE = "title";

        public static final String DEFAULT_SORT_ORDER = _ID + " ASC";
    }
}

SoundCloudBase的数据库

import android.net.Uri;
import android.provider.BaseColumns;
import es.manu.sd122.soundCloudBase.Config;

public class DB
{
    public static final String AUTHORITY = Config.AUTHORITY;
    public static final String PACKAGE = Config.PACKAGE;

    // This class cannot be instantiated
    protected DB() {}

    public static final class Uploads implements BaseColumns
    {
        // This class cannot be instantiated
        private Uploads() {}

        public static final String TABLE_NAME = "uploads";

        /**
         * The content:// style URL for this table
         */
        public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/uploads");

        /**
         * The MIME type of {@link #CONTENT_URI} providing a directory of app data entries.
         */
        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/" + PACKAGE + ".uploads";

        /**
         * The MIME type of a {@link #CONTENT_URI} sub-directory of a single app data entry.
         */
        public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/" + PACKAGE + ".uploads";

        public static final String TITLE = "title";
        public static final String PATH = "path";
        public static final String STATUS = "status";
        public static final String SHARING = "sharing";
        public static final String DESCRIPTION = "description";
        public static final String GENRE = "genre";
        public static final String TRACK_TYPE = "track_type";

        public static final String DEFAULT_SORT_ORDER = _ID + " DESC";
    }

    public static final class Tracks implements BaseColumns
    {
        // This class cannot be instantiated
        private Tracks() {}

        public static final String TABLE_NAME = "tracks";

        /**
         * The content:// style URL for this table
         */
        public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/tracks");

        /**
         * The MIME type of {@link #CONTENT_URI} providing a directory of app data entries.
         */
        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/" + PACKAGE + ".tracks";

        /**
         * The MIME type of a {@link #CONTENT_URI} sub-directory of a single app data entry.
         */
        public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/" + PACKAGE + ".tracks";

        public static final String TITLE = "title";
        public static final String ID = "id";
        public static final String STREAM_URL = "stream_url";
        public static final String DURATION = "duration";
        public static final String CLASS = "class";

        public static final String DEFAULT_SORT_ORDER = ID + " DESC";
    }
}

配置

public class Config
{


   public static final String AUTHORITY =   "es.manu.sd122.provider.soundCloudDroid";
        public static final String PACKAGE = "es.manu.sd122.soundCloudDroid";

    private Config()
    {}
}

自定义跟踪列表活动

import es.manu.sd122.soundCloudDroid.DB;
import android.app.ListActivity;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;

public class CustomTrackListsActivity extends ListActivity
{
    /**
     * The method called when the Activity is created.
     * <p>
     * Initializes the user interface.
     */
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        this.setContentView(R.layout.custom_track_lists);

        // Read uploads
        mCursor = getContentResolver().query(DB.TrackLists.CONTENT_URI, null, DB.TrackLists.RESOURCE + "<>\"\"", null, null);

        SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.track_list_item, mCursor,
                new String[] { DB.TrackLists.TITLE }, new int[] { android.R.id.text1 });
        setListAdapter(adapter);

        findViewById(R.id.use_menu).setVisibility(mCursor.getCount()<=2 ? View.VISIBLE : View.INVISIBLE);
    }

    public void onDestroy()
    {
        super.onDestroy();
        mCursor.close();
    }

    public boolean onCreateOptionsMenu(Menu menu)
    {
        super.onCreateOptionsMenu(menu);

        mArtistTracksMenuItem = menu.add("Search for Artists").setIcon(android.R.drawable.ic_menu_add);
        return true;
    }

    public boolean onOptionsItemSelected(MenuItem item) 
    {
        if(item == mArtistTracksMenuItem)
        {
            startActivity(new Intent(getApplication(), NewArtistTracksActivity.class));
            return true;
        }
        else return super.onOptionsItemSelected(item);
    }

    public void onListItemClick(ListView parent, View v, int position, long id)
    {
        mCursor.moveToPosition(position);
        Intent intent;
        if(id == 0)
            intent = new Intent(getApplication(), ViewTracksActivity.class);
        else
        {
            intent = new Intent(getApplication(), ViewOtherTracksActivity.class);
            intent.putExtra(DB.TrackLists.RESOURCE, mCursor.getString(1));
            intent.putExtra(DB.TrackLists.TITLE, mCursor.getString(2));
            intent.putExtra(DB.TrackLists._ID, id);
        }

        startActivity(intent);
    }

    private MenuItem mArtistTracksMenuItem;
    private Cursor mCursor;

}

我一直在寻找与Stackoverflow上的错误Unkown Uri Content相关的各种问题,但我仍然可以移动。
谢谢

lstz6jyr

lstz6jyr1#

我在其他开发人员身上也看到过同样的问题,但是LogCat中显示的错误消息中有

Caused by: java.lang.IllegalArgumentException: Unknown URI content://es.manu.sd122.provider.soundCloudDroid/tracklists
at es.manu.sd122.soundCloudBase.SoundCloudData.query(SoundCloudData.java:244)

未知的URI:

es.manu.sd122.provider.soundCloudDroid

因此必须更改为:

es.manu.sd122.soundCloudBase.SoundCloudData

相关问题