gpt4 book ai didi

android - CWAC 错误 : Unable to get provider com. commonsware.cwac.provider.StreamProvider

转载 作者:行者123 更新时间:2023-12-02 00:56:04 26 4
gpt4 key购买 nike

我正在将 CWAC StreamProvider 集成到我的代码中,但在运行我的代码后,我在 logcat 中看到无法获取提供程序 com.commonsware.cwac.provider.StreamProvider。我无法从互联网上的解决方案中解决它,因为我只找到了一些不适合我的解决方案。

提供者

     <provider
android:name="com.commonsware.cwac.provider.StreamProvider"
android:authorities="cz.revelio.tomiookamura"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="com.commonsware.cwac.provider.STREAM_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>

类变量

     private static final String AUTHORITY = "cz.revelio.tomiookamura";
private static final Uri PROVIDER = Uri.parse("content://"+AUTHORITY);
private static String ASSET_PATHS;

OnCreate 方法为分享定义了longClickListener

     button.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
Bundle params = new Bundle();
params.putInt("ButtonId", v.getId());
String btnName = "share_"+soubor;
mFirebaseAnalytics.logEvent(btnName, params);
AssetManager assetManager = getAssets();
ASSET_PATHS = "assets/" + soubor+".mp3";
setShareIntent();


return false;
}
});

分享功能

      private Intent setShareIntent(){
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("audio/*");

shareIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] {""});
shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Hláška");
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Text");
shareIntent.putExtra(Intent.EXTRA_STREAM, getURI());
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
shareIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);

return shareIntent;
}

private Uri getURI(){
return(PROVIDER
.buildUpon()
.appendPath(StreamProvider.getUriPrefix(AUTHORITY))
.appendPath(ASSET_PATHS)
.build());
}

错误

2019-01-15 22:32:54.081 29858-29858/cz.revelio.tomiookamura E/AndroidRuntime: FATAL EXCEPTION: main
Process: cz.revelio.tomiookamura, PID: 29858
java.lang.RuntimeException: Unable to get provider com.commonsware.cwac.provider.StreamProvider: java.lang.IllegalArgumentException: Failed to parse com.commonsware.cwac.provider.STREAM_PROVIDER_PATHS meta-data
at android.app.ActivityThread.installProvider(ActivityThread.java:5856)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5445)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5384)
at android.app.ActivityThread.-wrap2(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1545)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.IllegalArgumentException: Failed to parse com.commonsware.cwac.provider.STREAM_PROVIDER_PATHS meta-data
at com.commonsware.cwac.provider.StreamProvider.attachInfo(StreamProvider.java:208)
at android.app.ActivityThread.installProvider(ActivityThread.java:5853)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5445) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5384) 
at android.app.ActivityThread.-wrap2(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1545) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:154) 
at android.app.ActivityThread.main(ActivityThread.java:6119) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776) 
Caused by: java.lang.IllegalArgumentException: Could not build strategy for assets
at com.commonsware.cwac.provider.StreamProvider.parseStreamStrategy(StreamProvider.java:418)

Provider_paths.xml

<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<assets name="assets" path=""/>
</paths>

最佳答案

android:authorities="cz.revelio.tomiookamura"

您的值是:cz.revelio.tomiookamura

private static final String AUTHORITY = "com.anothergamedesigner.CatVimeoTest";

您在此处的值为:com.anothergamedesigner.CatVimeoTest

这些值是不一样的。它们必须相同。


另外,替换:

<assets name="assets" path=""/>

与:

<asset name="assets" path=""/>

关于android - CWAC 错误 : Unable to get provider com. commonsware.cwac.provider.StreamProvider,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54206935/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com