草庐IT

android - 检测联系人是否有照片

我有一个ImageView,我正在使用一个Uri显示联系人图片,它看起来总是与此类似:content://com.android.contacts/contacts/34/photo我如何才能检测到这张照片是否存在,如果它不存在,那么我想改用占位符(存储在我的可绘制文件夹中)。目前它只显示一张空白图像。 最佳答案 获取联系人照片uri的函数:publicUrigetPhotoUri(Integercontactid){CursorphotoCur=getContentResolver().query(ContactsContract

Android GCM PushNotification - 在应用程序中添加自定义声音文件

我正在成功获取GCM推送通知。现在我想添加自定义声音文件而不是默认声音。我试过Urifromfile:///res/raw/pop.mp3在Notification.DEFAULT_SOUND;但没有成功。如果您有更好的解决方案,请分享。我的GCMIntentService.java方法代码如下-/***Issuesanotificationtoinformtheuserthatserverhassentamessage.*/privatestaticvoidgenerateNotification(Contextcontext,Stringmessage){System.out.pr

android - Spotify 登录错误 INVALID_CLIENT : Invalid redirect URI android

我正在制作一个包含spotify集成的应用程序,我点击了此链接https://developer.spotify.com/technologies/spotify-android-sdk/tutorial/通过引用此链接,我将“festevo://callback”作为回调重定向URI当我每次都遇到同样的错误时尝试登录spotify。请告诉我为什么会这样......谢谢。 最佳答案 我看到了一些可能出错的地方:这很简单,因为您在输入重定向URI后没有保存它。(仔细检查MyApplications。)您没有在应用程序的list中正确指

android - 如何将 ExifInterface 与流或 URI 一起使用

我正在编写一个可以从Android中的“共享方式”菜单发送照片URI的应用。您获得的URI类型是content://media/external/images/media/556但是ExifInterface需要一个标准文件名。那么如何读取该文件的exif数据(我只想要方向)?这是我的(非工作)代码:Uriuri=(Uri)extras.getParcelable(Intent.EXTRA_STREAM);ContentResolvercr=getContentResolver();InputStreamis=cr.openInputStream(uri);Bitmapbm=Bitma

android - Mockito Uri.parse 总是返回 null

我有这样的制作方法:publicbooleanonShouldOverrideUrlLoading(Stringurl){booleanisConsumed=false;if(url.contains("code=")){Uriuri=Uri.parse(url);StringauthCode=uri.getQueryParameter("code");mView.authCodeObtained(authCode);isConsumed=true;}returnisConsumed;}我有这个Mockito测试方法:@TestpublicvoidonShouldOverrideUrl

android - Facebook Android sdk 在身份验证上抛出丢失的重定向 uri

我正在使用Facebookandroidsdk用我的安卓应用程序。在开发我的开发版本时,我的应用程序一切正常。当我最终向公众发布我的应用程序时,当人们尝试对我的应用程序进行身份验证时,facebook身份验证会吐出一个丑陋的错误:APIErrorcode:100APIErrordescription:InvalidparameterErrorMessage:RequiresvalidredirectURI似乎facebook认为我正在对它们进行浏览器重定向并缺少重定向uri以返回到我的应用程序,但我使用的是androidsdk,其中你不发送重定向uri,你有一个回调监听器:facebo

android - 是否可以使用 Uri.Builder 而没有 "//"部分?

我正在尝试构建一个mailto:uri以使用GMail应用程序发送邮件。我想使用android.net.Uri.Builder类来执行此操作,但生成的uri的格式为mailto://test@example.com,这使得GMail应用认为收件人是//test@example.com,而不仅仅是test@example.com。我最终这样做了:StringuriStr=uriBuilder.toString();uriStr=uriStr.replaceAll("//","");finalUriuri=Uri.parse(uriStr);但显然,这是一个丑陋的hack...没有//部分

android - 如何获取可绘制对象的文件实例?

下面是我处理logo打印的代码。Logo位于res/drawable文件夹中。当我运行该应用程序时,它会抛出:java.io.FileNotFoundException:/android.resource:/com.android.test/2130837505(Nosuchfileordirectory).有什么建议吗?publicbooleanprintLogo(){Urilogo_path=Uri.parse("android.resource://com.android.test/"+R.drawable._logo);Filelogo=newFile(logo_path.to

android - 如何转换内容://Uri into actual file path?

如何获取content://uri指向图像的SD卡上的实际文件路径? 最佳答案 我修改了@hooked82链接到的代码:protectedStringconvertMediaUriToPath(Uriuri){String[]proj={MediaStore.Images.Media.DATA};Cursorcursor=getContentResolver().query(uri,proj,null,null,null);intcolumn_index=cursor.getColumnIndexOrThrow(MediaStore

android - 在android中将真实路径格式转换为Uri

例如真实路径是mnt/sdcard/image_1.jpgUri路径是这样的content://media/external/images/media/140UriphotoUri=Uri.parse("content://media/external/images/media/140");Log.d("selectedphoto",""+photoUri);selectedImagePath=getPath(photoUri);publicStringgetPath(Uriuri){String[]projection={MediaStore.Images.Media.DATA};C