Questions tagged «android»

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

6
如何确定网络类型是2G,3G还是4G
我的应用程序上有一个指示器来显示网络类型(2G或3G或4G),但是获得网络类型后,我如何知道它应该属于哪个速度类别? 我知道如何检测网络类型: private TelephonyManager telephonyManager; telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); CurrentNetworkType = telephonyManager.getNetworkType(); 给定可能的返回值: // public static final int NETWORK_TYPE_1xRTT // Since: API Level 4 // Current network is 1xRTT // Constant Value: 7 (0x00000007) // // public static final int NETWORK_TYPE_CDMA // Since: API Level 4 // Current network is …

4
如何在地图片段API v2布局顶部添加按钮
我正在尝试使用API​​ v2在android中显示地图。 我想要UI这样的东西。但是,每当我尝试在布局中添加按钮时,它都不会反映在输出中,因此 我能够获得没有按钮的地图。我需要按钮来与地图集成,例如 Mylayout.xml的以下代码: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MapActivity" > <RelativeLayout android:layout_width="match_parent" android:layout_height="48dp"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <RadioGroup android:id="@+id/radio_group_list_selector" android:layout_width="0dp" android:layout_height="match_parent" android:layout_gravity="center_horizontal|center_vertical" android:gravity="center_horizontal" android:orientation="horizontal" android:layout_weight="1" > <RadioButton android:id="@+id/radioPopular" android:layout_width="0dp" android:layout_height="match_parent" android:gravity="center_horizontal|center_vertical" android:text="@string/Popular" android:layout_weight="1" android:button="@null" android:background="@drawable/shape_radiobutton" android:layout_marginBottom="4dp" android:layout_marginTop="4dp" android:layout_marginLeft="4dp" android:textColor="@drawable/textcolor_radiobutton" /> <View android:id="@+id/VerticalLine" android:layout_width="1dip" android:layout_height="wrap_content" android:layout_marginBottom="4dip" android:layout_marginTop="4dip" android:background="#aaa" /> …

11
Widget.AppCompat.Button colorButtonNormal显示为灰色
我有values:styles.xml: <style name="AppTheme.Button" parent="Base.Widget.AppCompat.Button"> <item name="colorButtonNormal">@color/my_color</item> <item name="android:textColor">@android:color/white</item> </style> 并values-v21:styles.xml带有: <style name="AppTheme.Button" parent="Base.Widget.AppCompat.Button"> <item name="android:colorButtonNormal">@color/my_color</item> <item name="android:textColor">@android:color/white</item> </style> 和应用风格 <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> <item name="android:buttonStyle">@style/AppTheme.Button</item> </style> 但是颜色显示为灰色而不是 @color/my_color

12
Android:从preferences.xml启动Activity
我想使用<intent>标签从默认的preferences.xml启动一个Activity。活动已经过良好的测试,问题不在于此。(我在我的应用程序中扩展了PreferenceActivity,因此preferences.xml随之“出现”了)请看一下代码,这是怎么回事? preferences.xml: .... <PreferenceCategory android:title="@string/titleEtcSetup"> <PreferenceScreen android:key="renameCourses" android:title="@string/titleRenameCourses" android:summary="@string/textRenameDisplayedCoursesNames"> <intent android:action="android.intent.action.VIEW" android:targetPackage="my.notifier.ui" android:targetClass="my.notifier.ui.EditCoursesNamesActivity" /> </PreferenceScreen> ..... </PreferenceCategory> ..... manifest.xml: .... <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="my.notifier.ui".... .... <activity android:name=".EditCoursesNamesActivity" android:label="@string/titleRenameCourses"> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> ..... 当我按下“ renameCourses项”时,活动没有调用,什么也没发生。LogCat是“清除”的,没有错误或警告。我搜索了很多东西,但没有找到解决方案,也许我只是错过了一些东西……请帮助!


5
在Android中初始化Games Client
我正在尝试新的Google Play游戏服务。 首先,我遵循了此方法https://developers.google.com/games/services/android/quickstart ,然后完成了此https://developers.google.com/games/services/android/init 我最终像这样: 05-16 20:01:39.034: E/AndroidRuntime(18257): FATAL EXCEPTION: main 05-16 20:01:39.034: E/AndroidRuntime(18257): java.lang.IllegalStateException: A fatal developer error has occurred. Check the logs for further information. 05-16 20:01:39.034: E/AndroidRuntime(18257): at com.google.android.gms.internal.p$f.a(Unknown Source) 05-16 20:01:39.034: E/AndroidRuntime(18257): at com.google.android.gms.internal.p$f.a(Unknown Source) 05-16 20:01:39.034: E/AndroidRuntime(18257): at com.google.android.gms.internal.p$b.p(Unknown Source) 05-16 20:01:39.034: E/AndroidRuntime(18257): at com.google.android.gms.internal.p$a.handleMessage(Unknown …

17
如何判断“移动网络数据”是启用还是禁用(即使通过WiFi连接)?
我有一个应用程序,希望能够从远程查询中获取连接状态报告。 我想知道是否已连接WiFi,以及是否通过移动网络启用了数据访问。 如果WiFi超出范围,我想知道我是否可以依靠移动网络。 问题是,当我通过WiFi连接时,启用的数据始终返回true,并且只有在未通过WiFi连接时,我才能正确查询移动网络。 我所看到的所有答案都建议通过轮询来查看当前的连接,但是我想知道是否需要移动网络,即使目前我可能通过WiFi连接。 无论如何,是否无需轮询即可查看是否已连接是否启用了移动网络数据? 编辑 因此,当通过WiFi连接时,如果我转到设置并取消选择“启用数据”,然后在我的应用中执行以下操作: boolean mob_avail = conMan.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).isAvailable(); mob_avail返回为“ true”,但是我已禁用了移动网络数据,因此我希望它为“ false” 如果我关闭WiFi,则(正确)没有连接,因为我禁用了移动网络数据。 因此,当我通过WiFi连接时,如何检查是否启用了移动网络数据? 更新 我查看了ss1271的注释中建议的getAllNetworkInfo() 我在以下3种情况下输出了有关移动网络的返回信息 WiFi关闭-开启移动数据 WiFi打开-移动数据关闭 WiFi打开-移动数据打开 并得到以下结果: 关闭WiFi: mobile [HSUPA],状态:CONNECTED / CONNECTED,原因:未知,额外:互联网,漫游:false,故障转移:false,isAvailable:true,featureId:-1,userDefault:false 开启WiFi /关闭手机 NetworkInfo:类型:mobile [HSUPA],状态:DISCONNECTED / DISCONNECTED,原因:connectionDisabled,额外:(无),漫游:false,故障转移:false,isAvailable:true,featureId:-1,userDefault:false 开启WiFi /开启手机 NetworkInfo:类型:mobile [HSPA],状态:DISCONNECTED / DISCONNECTED,原因:connectionDisabled,额外:(无),漫游:false,故障转移:false,isAvailable:true,featureId:-1,userDefault:false 因此,您可以看到isAvailable每次都返回true,并且状态仅在WiFi影响时显示为Disconnected。 澄清说明 我不希望查看手机当前是否通过移动网络连接。我AM试图建立在移动网络中的用户是否已启用/禁用数据访问。他们可以通过转到设置->无线和网络设置->移动网络设置->已启用数据来启用和禁用此功能。

11
Android WebView“电话:”链接显示未找到网页
我试图让我的android webview应用程序打开tel:手机链接。每次我打开电话链接时,它都会很好地工作并打开电话。但是,一旦完成通话并返回到应用程序,该页面就会显示“找不到网页tel:0000000000”。然后,我必须再次单击“后退”按钮才能进入单击电话号码的页面。 有没有办法让它打开TEL链接而不尝试在Webview中查找页面并在电话中打开它? 这是我在WebView中使用的代码,以覆盖其对TEL和Mailto链接的处理: public boolean shouldOverrideUrlLoading(WebView view, String url) { if (url.startsWith("mailto:") || url.startsWith("tel:")) { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); startActivity(intent); } view.loadUrl(url); return true; } 任何帮助,将不胜感激。我在过去的2个小时里一直在搜索古德,但未能给出任何答案。



13
如何将Android Studio设置为完全脱机工作?
我的带宽非常慢,因此我试图将所有必需的文件保留在本地计算机上,以使Android Studio完全脱机。当我单击“新建项目”时,它总是尝试下载名为gradle-1.6-bin.zip的文件,该文件我已下载并尝试通过插件管理器在本地安装,但它给了我一个错误: 无法从gradle-1.6-bin.zip文件加载插件描述符 那么,我还需要下载其他哪些文件,以及如何正确安装它们才能与Android Studio脱机使用?

11
如何为Android应用程序按降序排列我的SQLITE数据库?
以降序显示数据的最有效方法是什么? public String getRank() { String[] rank = new String[]{ KEY_ROWID }; Cursor c = scoreDb.query(DATABASE_TABLE, rank, null, null, null, null, null); //reading information from db. String rankResult = ""; int iRow = c.getColumnIndex(KEY_ROWID); //Cursor looking for column setting equal to these ints. for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext()) { //Move to …


6
Android Studio无法为参数找到方法runProguard()?
/Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home/bin/java "- com.intellij.rt.execution.application.AppMain org.gradle.launcher.GradleMain --build-file /Users/Tom/Documents/Git_open_sources/android-material-drawer-template/app/build.gradle FAILURE: Build failed with an exception. * Where: Build file '/Users/Tom/Documents/Git_open_sources/android-material-drawer-template/app/build.gradle' line: 16 * What went wrong: A problem occurred evaluating project ':app'. > Could not find method runProguard() for arguments [false] on BuildType_Decorated{name=release, debuggable=false, testCoverageEnabled=false, jniDebuggable=false, pseudoLocalesEnabled=false, renderscriptDebuggable=false, renderscriptOptimLevel=3, applicationIdSuffix=null, versionNameSuffix=null, minifyEnabled=false, zipAlignEnabled=true, …

14
错误:Windows上的文件路径过长,请保持240个字符以下
因此,我对build.gradle(app)文件进行了一些更改,android studio给了我这个错误(在新标签页中打开图像以更好地查看): 我的build.gradle(app)文件(这不是经过编辑的文件,我删除了新的代码行,但仍然没有运气/解决方案。): 直到我在build.gradle(app)文件中进行了一些更改之前,一切工作都很好,但是随后我删除了这些新的代码行,而android studio仍然不断给我错误。该错误与编译'com.google.android.gms:play-services:8.3.0'有关。我尝试删除/重命名指定文件夹内的png图像,但是当我重建项目时,会自动下载png图像。我的build.gradle(project)文件包含类路径'com.android.tools.build:gradle:1.5.0'。我想知道导致此错误的原因以及如何解决?非常感谢。

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.