我有一个非常基本的要求。我需要从我可以使用的设备相机中获取的最后一张图像(及其缩略图)。
我使用以下代码来获取图像缩略图:
String[] projection={MediaStore.Images.Thumbnails._ID,MediaStore.Images.Thumbnails.IMAGE_ID,
MediaStore.Images.Thumbnails.KIND,MediaStore.Images.Thumbnails.DATA};
Cursor cursor=MediaStore.Images.Thumbnails.queryMiniThumbnails(getContentResolver(),MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, MediaStore.Images.Thumbnails.MINI_KIND, projection);
Run Code Online (Sandbox Code Playgroud)
以下是实际图像:
String[] largeimage_projection={MediaStore.Images.ImageColumns._ID,MediaStore.Images.ImageColumns.DATA,};
String largeFileSort=MediaStore.Images.ImageColumns._ID+" DESC";
Cursor cursor=getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, largeimage_projection, null, null, sort);
Run Code Online (Sandbox Code Playgroud)
但是,在我的 Samsung Galaxy Tab 8.9 上运行该应用程序时,出现以下错误:
对于缩略图:
没有内容条目://media/external/images/Thumnails/0
对于图像:
内容无条目://media/external/images/media/0
在检查设备时,我发现图像的默认位置是“/mnt/sdcard/DCIM/Camera/”
此外,我无法使用 onActivityResult() 方法中返回的“intent.getExtras()”,因为我的选项卡总是将其设为 null。
谁能告诉我我哪里出错了?谢谢。
我正在使用startForeground(id,notification)从intent服务创建通知.
Random r=new Random();
int id=r.nextInt(9999);
Builder notice2=new Notification.Builder(getApplicationContext())
.setContentTitle(call.getName())
.setAutoCancel(true)
.setContentIntent(intent)
.setContentText("content")
.setSmallIcon(com.project.calltracker.R.drawable.ic_alert)
.setLargeIcon(BitmapFactory.decodeResource(getResources(), com.project.calltracker.R.drawable.ic_logo));
startForeground(id, notice2.getNotification());
Run Code Online (Sandbox Code Playgroud)
这里我设置了AutoCancel(true)
但是当我点击通知时它不会消失?
我真的很困惑.我已经尝试过几个小时但仍然没有运气!
请帮忙!
谢谢!
我有一个简单的应用程序,可以轮询服务以在回收器视图中显示国家/地区列表。在这里,每当国家/地区列表发生任何变化时,我都会使用 LiveData 更新回收器视图。问题是,LiveData 的 onChanged 方法仅在第一次调用 setValue 时才会被调用。但之后如果数据有任何进一步的更改,onChanged 就不会被调用?
以下是我的代码以获取更多信息 -
//Setup observer
Observer<List<CountryModel>> myObserver = new Observer<List<CountryModel>>() {
@Override
public void onChanged(@Nullable List<CountryModel> countryModels) {
mCountryList = countryModels;
//Update recyclerview
myAdapter.updateRecyclerView(mCountryList);
}
};
//Set Observer for Viewmodel
countryViewModel.getmCountryList().observe(this,myObserver);
Run Code Online (Sandbox Code Playgroud)
公共类 CountryViewModel 扩展 AndroidViewModel { 私有 MutableLiveData> mCountryList; 私人 MyRetrofitClient myRetrofitClient;
public CountryViewModel(@NonNull Application application) {
super(application);
}
public void init(){
mCountryList = new MutableLiveData<>();
myRetrofitClient = new MyRetrofitClient();
**mCountryList = myRetrofitClient.getCountryList(); //This works**
pollCountryList();
}
//Create polling request …Run Code Online (Sandbox Code Playgroud) 下面是我的代码-
try {
InputStream inputStream = getAssets().open("thumbnail.jpg");
exifInterface = new ExifInterface(inputStream);
exifInterface.setAttribute(ExifInterface.TAG_ARTIST,"TEST INPUT");
exifInterface.saveAttributes();
} catch (IOException e) {
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
我在线上exifInterface.saveAttributes()收到以下错误 -
java.io.IOException:ExifInterface 不支持保存当前输入的属性。
我不确定错误是由于图像文件还是由于属性引起的。我正在努力挽救。我还在网上寻找可能的解决方案(例如 Sanselan),但不确定它是否能解决这个问题。
有人可以解释如何解决这个问题吗?
谢谢!
在通过GCM向Android设备发送通知时,我收到以下响应:
设备订阅已过期:PushSharp.Android.GcmPushService - > AppId
由于这个问题,我在手机上遇到随机问题.例如,应用程序在接收器上接收额外的回调.
有人可以提供有关此错误的更多详细信息吗?什么时候发生?它与设备ID注册类似吗?需要做些什么来处理这种情况?
谢谢!