Questions tagged «android»

Android是Google的移动操作系统,用于对数字设备(智能手机,平板电脑,汽车,电视,Wear,Glass和IoT)进行编程或开发。对于与Android相关的主题,请使用特定于Android的标签,例如android-intent,android-activity,android-adapter等。对于与开发或编程无关但与Android框架相关的问题,请使用以下链接:https:// android.stackexchange.com。

9
与依赖项“ com.android.support:support-annotations”冲突。应用(23.1.0)和测试应用(23.0.1)的已解决版本不同
构建时出现以下错误: Conflict with dependency 'com.android.support:support-annotations'. Resolved versions for app (23.1.0) and test app (23.0.1) differ. 这些是我的gradle依赖 dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') compile 'com.android.support:support-v4:23.1.0' compile 'com.android.support:appcompat-v7:23.1.0' compile 'com.android.support:design:23.1.0' compile 'com.android.support:cardview-v7:23.1.0' compile 'com.android.support:recyclerview-v7:23.1.0' compile 'com.squareup.retrofit:retrofit:1.9.0' compile 'com.squareup.okhttp:okhttp:2.4.0' compile 'com.squareup.picasso:picasso:2.5.2' compile 'com.jakewharton:butterknife:7.0.1' compile 'com.squareup:otto:1.3.8' compile 'com.snappydb:snappydb-lib:0.5.2' compile 'com.esotericsoftware.kryo:kryo:2.24.0' compile 'com.google.dagger:dagger:2.0.1' apt …


7
如何在Android上使用Retrofit处理“无互联网连接”
我想处理没有互联网连接的情况。通常我会跑: ConnectivityManager cm = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); boolean isConnected = activeNetwork != null && activeNetwork.isConnectedOrConnecting(); (从此处开始),然后再将请求发送到网络,并通知用户是否没有互联网连接。 从我看来,Retrofit不能专门处理这种情况。如果没有互联网连接,我将RetrofitError超时作为原因。 如果我想使用Retrofit将这种检查合并到每个HTTP请求中,该怎么办?还是我应该做。 谢谢 亚历克斯
119 android  retrofit 

11
避免Android Lint抱怨未翻译的字符串
是否可以指定value-* 目录中文件中的字符串不是故意翻译成其他语言?我有一堆所有语言都通用的字符串,不需要翻译,因此我已经unlocalized-strings.xml在values目录中创建了一个文件。要在整个项目上禁用此检查,我只想在某些XML文件中禁用它。 "title_widget_updater_service" is not translated in de, en, en-rUS, it Issue: Checks for incomplete translations where not all strings are translated Id: MissingTranslation If an application has more than one locale, then all the strings declared in one language should also be translated in all other languages. By default …

30
无法接受许可协议Android SDK Platform 24
尝试在Cordova项目上安装android平台时出现以下错误。我一直在遵循此指南:https : //cordova.apache.org/docs/en/latest/guide/cli/ 执行以下操作时发生错误:$ cordova platform add android --save 配置根项目“ android”时发生问题。您尚未接受以下SDK组件的许可协议:[Android SDK Platform 24]。 我一直在寻找可以接受Android SDK Platform 24许可协议的方法,但是没有真正的运气。 提前谢谢你。

15
找不到构建工具版本23.0.1
我正在尝试使用react-native构建我的第一个应用程序。 我正在关注这两个教程: https://facebook.github.io/react-native/docs/getting-started.html#content https://facebook.github.io/react-native/docs/android-setup.html 我确定我从第二个链接安装了所有要求,但是当我尝试使用运行应用程序时react-native run-android,出现以下错误: 我在运行genymotion时执行了此命令。 这就是我在Android SDK中安装的所有内容: 我尝试安装Android构建工具23.0.1,但出现此错误: 我该怎么办?

9
如何在毕加索中使用磁盘缓存?
我正在使用Picasso在我的android应用中显示图像: /** * load image.This is within a activity so this context is activity */ public void loadImage (){ Picasso picasso = Picasso.with(this); picasso.setDebugging(true); picasso.load(quiz.getImageUrl()).into(quizImage); } 我已启用调试,并且始终显示红色和绿色。但是从不显示黄色 现在,如果我下次加载同一张图片,并且互联网不可用,则无法加载图片。 问题: 它没有本地磁盘缓存吗? 我如何启用磁盘缓存,因为我将多次使用相同的映像。 我是否需要向Android清单文件添加一些磁盘权限?




5
Android偏好设置:当用户未使用偏好设置屏幕时,如何加载默认值?
我正在使用PreferenceActivity来让用户设置一些值。我用定义的首选项为它提供xml文件。 我已经android:defaultValue=""为他们准备好了。 启动应用程序时,我需要首选项,或者如果尚未手动设置首选项,则需要默认值: SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); boolean value = prefs.getBoolean("key"), false); 但是,当android:defaultValue="true"我仍然得到false。因此,看起来在XML中设置的defaultValues并没有在任何地方使用,而是在初始化首选项屏幕时使用。 我不想在getBoolean()方法中对默认值进行硬编码。因此,有没有办法仅在1个地方定义默认值?

3
有可以下载android虚拟设备的仓库吗?[关闭]
关闭。此问题不符合堆栈溢出准则。它当前不接受答案。 想改善这个问题吗?更新问题,使其成为Stack Overflow 的主题。 7年前关闭。 改善这个问题 有谁知道,如果供应商提供了产品,或者是否有一个网站可以为市场上的现有android设备下载AVD配置文件,以便您可以在模拟器中运行您的应用程序,并基本上了解它们将如何在上述设备上运行? 我知道创建一个新设备非常容易,但是如果能够为每个设备下载配置文件并运行它,那将是很棒的。
119 android  avd 

12
如何在Android中播放铃声/警报声音
我到处都在寻找如何在Android中播放铃声/警报声音。 我按下一个按钮,然后要播放铃声/警报声音。我找不到一个简单直接的示例。是的,我已经看过了闹钟的源代码...但是它并不简单,我无法对其进行编译。 我无法完成这项工作: Uri alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM); mMediaPlayer = new MediaPlayer(); mMediaPlayer.setDataSource(this, alert); final AudioManager audioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE); if (audioManager.getStreamVolume(AudioManager.STREAM_ALARM) != 0) { player.setAudioStreamType(AudioManager.STREAM_ALARM); player.setLooping(true); player.prepare(); player.start(); } 我收到此错误: 04-11 17:15:27.638: ERROR/MediaPlayerService(30): Couldn't open fd for content://settings/system/ringtone 所以..如果有人知道如何播放默认铃声/警报,请告诉我。 我不想上传任何文件。只需播放默认铃声即可。

7
显示片段中的对话框?
我有一些片段需要显示常规对话框。在这些对话框上,用户可以选择是/否答案,然后片段应相应地表现。 现在,Fragment该类没有onCreateDialog()重写的方法,所以我想我必须在contains中实现外部对话框Activity。可以,但是随后Activity需要以某种方式向片段报告所选答案。我当然可以在这里使用回调模式,因此该片段会在自己Activity的侦听器类中注册自己,并且Activity将通过该事件或类似事件来报告答案。 但这对于一个简单的任务来说似乎是一个很大的混乱,因为在片段中显示“简单”是-否对话框。而且,这样我Fragment就不会那么独立了。 有没有更清洁的方法可以做到这一点? 编辑: 这个问题的答案并没有真正详细解释如何使用DialogFragments显示来自Fragments的对话框。因此,AFAIK的方法是: 显示片段。 需要时,实例化DialogFragment。 使用将原始片段设置为该DialogFragment的目标.setTargetFragment()。 使用原始片段中的.show()显示DialogFragment。 当用户在此DialogFragment中选择某个选项时,将有关此选择的信息通知原始Fragment(例如,用户单击“是”),则可以使用.getTarget()获取原始Fragment的引用。 关闭DialogFragment。

8
从适配器调用活动方法
是否可以调用Activityfrom中定义的方法ListAdapter? (我想打一个Button在list's行单击此按钮时,它应该执行的方法,即在相应的活动定义。我试图设置onClickListener在我ListAdapter,但我不知道该怎么称呼这种方法,什么是它的路径。 ..) 当我使用时Activity.this.method(),出现以下错误: No enclosing instance of the type Activity is accessible in scope 任何想法 ?

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.