Questions tagged «android»

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


12
Android模拟器无法分配内存8
当我尝试从Eclipse运行WXGA800仿真器时,出现了这样的错误 Failed to allocate memory: 8 This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. 我也检查了以下链接 分配内存失败:8 Android:无法分配内存 我曾尝试在模拟器中减小RAM大小,并增大Java堆大小和ramsize,但仍然遇到相同的错误。

26
从Android应用程序打开Facebook页面?
从我的Android应用程序中,我想在官方Facebook应用程序中打开一个指向Facebook个人资料的链接(当然,如果已安装该应用程序)。对于iPhone,存在fb://URL方案,但是在我的Android设备上尝试相同的操作会抛出ActivityNotFoundException。 是否有可能通过代码在官方Facebook应用程序中打开Facebook个人资料?

12
我们如何在Android中使用runOnUiThread?
我是Android的新手,正在尝试使用UI-Thread,因此我编写了一个简单的测试活动。但是我想我误会了一些东西,因为单击按钮后,该应用程序不再响应 public class TestActivity extends Activity { Button btn; int i = 0; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); btn = (Button)findViewById(R.id.btn); btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { runThread(); } }); } private void runThread(){ runOnUiThread (new Thread(new Runnable() { public void run() { while(i++ …
157 android  ui-thread 

16
应用程序错误-与服务器的连接失败。(文件:///android_asset/www/index.html)
应用程序在启动时死(与服务器的连接失败) 我有一个使用PhoneGap BUILD编写的Android应用程序。该应用程序之前运行良好,但现在看来,在优化我的应用程序后,我收到了此错误(仅某些UI更改) 1)当我启动应用程序时,我通常会得到: 应用程序错误-与服务器的连接失败。(文件:///android_asset/www/index.html) 很抱歉,如果这是任何问题的重复。我在这里看到过类似的问题,但是找不到完美的答案或解决方案。就我而言,直到我最后一次更改,它都可以正常工作。
157 android  cordova 

22
如何关闭Android应用程序?
我想关闭我的应用程序,以使其不再在后台运行。 怎么做?这是在Android平台上的良好做法吗? 如果我依靠“后退”按钮,它将关闭应用程序,但仍处于后台。甚至有一个名为“ TaskKiller”的应用程序只是在后台杀死那些应用程序。
157 android 


28
ScrollView中的ListView在Android上不滚动
我有一个滚动的麻烦ListView内ScrollView。我有一个Activity,在顶部具有一些EditTexts,然后是一个带有两个选项卡的选项卡主机,每个选项卡具有一个ListView。当EditText视图成为焦点时,出现软键盘,并且当我有ScrollView时,内容可以滚动。但是问题来了,当ListViews中有更多项(选项卡中的项)时,即使有更多项,我也无法滚动ListView。 以下是布局XML: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="?backgroundImage" android:orientation="vertical"> <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="50dip" android:layout_alignParentBottom="true" android:layout_margin="10dip" android:id="@+id/buttons"> <Button android:text="Save" android:layout_margin="2dip" android:textSize="20dip" android:id="@+id/btnSaveorUpdate" android:layout_height="wrap_content" android:layout_width="145dip"></Button> <Button android:text="Cancel" android:layout_margin="2dip" android:textSize="20dip" android:id="@+id/btnCancelorDelete" android:layout_height="wrap_content" android:layout_width="145dip"></Button> </LinearLayout> <ScrollView android:layout_above="@id/buttons" android:layout_width="fill_parent" android:layout_height="fill_parent" android:fillViewport="true" android:layout_margin="10dip"> <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_margin="10dip"> <TextView android:text="Bill details" android:textColor="?textColorDark" android:layout_alignParentTop="true" android:id="@+id/txtEnterDetails" …

14
在圆ci中找不到com.android.tools.build:gradle:3.0.0-alpha1
我将gradle插件更新为最新版本:com.android.tools.build:gradle:3.0.0-alpha1 并发生了此错误: export TERM="dumb" if [ -e ./gradlew ]; then ./gradlew test;else gradle test;fi FAILURE: Build failed with an exception. What went wrong: A problem occurred configuring root project 'Android-app'. Could not resolve all dependencies for configuration ':classpath'. Could not find com.android.tools.build:gradle:3.0.0-alpha1. Searched in the following locations: https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0-alpha1/gradle-3.0.0-alpha1.pom https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0-alpha1/gradle-3.0.0-alpha1.jar Required …

3
形状xml中的边框
我正在尝试使一个可绘制的按钮使用。我希望它具有这种颜色,并带有2px的边框。 一切正常,除非我无法显示边框... <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <gradient android:startColor="@color/bar_clicked_dark" android:endColor="@color/bar_clicked_light" android:angle="90"/> <corners android:bottomLeftRadius="0dp" android:topLeftRadius="15dp" android:bottomRightRadius="15dp" android:topRightRadius="0dp" /> <stroke android:width="2dp" color="#ff00ffff" /> </shape>

17
Google Services 3.0.0缺少api_key /当前密钥
自从我使用最新版本的google服务和库(9.0.0)升级了该项目后,我遇到了一个奇怪的问题: 坡度控制台: :app:processDebugGoogleServices Parsing json file: /Users/cyrilmorales/Documents/Projects/mobilemeans-punainenristi/app/google-services.json :app:processDebugGoogleServices FAILED Error:Execution failed for task ':app:processDebugGoogleServices'. > Missing api_key/current_key object Information:BUILD FAILED build.gradle(根目录): dependencies { classpath 'com.android.tools.build:gradle:2.2.0-alpha1' classpath 'com.google.gms:google-services:3.0.0' } build.gradle(app): dependencies { .... compile 'com.google.android.gms:play-services-analytics:9.0.0' compile 'com.google.android.gms:play-services-gcm:9.0.0' compile 'com.google.android.gms:play-services-maps:9.0.0' compile 'com.google.android.gms:play-services-location:9.0.0' ... } apply plugin: 'com.google.gms.google-services' 但是,它与8.4.0和google-services 2.1.0中的播放服务库一起很好地工作 您对解决方案有什么想法吗?


18
如何在片段中访问getSupportFragmentManager()?
我有一个FragmentActivity,我想在其中使用一个地图片段。我在获取支持片段管理器进行访问时遇到问题。 if (googleMap == null) { googleMap = ((SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map1)).getMap(); // check if map is created successfully or not if (googleMap == null) { Toast.makeText(getApplicationContext(), "Sorry! unable to create maps", Toast.LENGTH_SHORT) .show(); } } // create marker MarkerOptions marker = new MarkerOptions().position( new LatLng(latitude, longitude)).title("Hello Maps "); CameraPosition cameraPosition …

25
如何在Android TextView中添加换行符?
我正在尝试在TextView中添加换行符。 我试过建议\ n,但这无济于事。这是我设置文字的方式。 TextView txtSubTitle = (TextView)findViewById(r.id.txtSubTitle); txtSubTitle.setText(Html.fromHtml(getResources().getString(R.string.sample_string))); 这是我的字符串: <string name="sample_string">some test line 1 \n some test line 2</string> 它应该显示如下: some test line 1 some test line 2 但它显示如下:some test line 1 some test line 2。 我想念什么吗?

9
使用翻新功能刷新OAuth令牌,而无需修改所有调用
我们正在Android应用中使用Retrofit,以与OAuth2安全服务器进行通信。一切正常,我们使用RequestInterceptor在每个调用中都包含访问令牌。但是,有时访问令牌将过期,并且令牌需要刷新。当令牌到期时,下一个调用将返回未经授权的HTTP代码,因此易于监视。我们可以通过以下方式修改每个Retrofit调用:在失败回调中,检查错误代码,如果错误代码等于Unauthorized,则刷新OAuth令牌,然后重复Retrofit调用。但是,为此,应修改所有调用,这不是一个易于维护的好的解决方案。有没有一种方法可以修改所有Retrofit调用?

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.