当前位置: 代码迷 >> 综合 >> android 7.0 手机android.content.res.XmlResourceParser android.content.pm.ProviderInfo.loadXmlMetaData
  详细解决方案

android 7.0 手机android.content.res.XmlResourceParser android.content.pm.ProviderInfo.loadXmlMetaData

热度:66   发布时间:2023-10-20 12:08:05.0
1. 报错
Attempt to invoke virtual method 'android.content.res.XmlResourceParser android.content.pm.ProviderInfo.loadXmlMetaData(android.content.pm.PackageManager, java.lang.String)' on a null object reference2.位置

Uri contentUri = FileProvider.getUriForFile(BaseUploadActivity.this,context.getPackageName() + ".provider", tempFile);
3.context.getPackageName() + ".provider"  必须和 清单文件的android:authorities="包名.provider"  一致
4.api说明/*** Return a content URI for a given {@link File}. Specific temporary* permissions for the content URI can be set with* {@link Context#grantUriPermission(String, Uri, int)}, or added* to an {@link Intent} by calling {@link Intent#setData(Uri) setData()} and then* {@link Intent#setFlags(int) setFlags()}; in both cases, the applicable flags are* {@link Intent#FLAG_GRANT_READ_URI_PERMISSION} and* {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION}. A FileProvider can only return a* <code>content</code> {@link Uri} for file paths defined in their <code>&lt;paths&gt;</code>* meta-data element. See the Class Overview for more information.** @param context A {@link Context} for the current component.
 * @param authority The authority of a {@link FileProvider} defined in a* {@code <provider>} element in your app's manifest.* @param file A {@link File} pointing to the filename for which you want a* <code>content</code> {@link Uri}.* @return A content URI for the file.* @throws IllegalArgumentException When the given {@link File} is outside* the paths supported by the provider.*/
public static Uri getUriForFile(@NonNull Context context, @NonNull String authority,@NonNull File file) {final PathStrategy strategy = getPathStrategy(context, authority);return strategy.getUriForFile(file);
}
  相关解决方案