Questions tagged «android»

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

8
如何检测我的应用程序中Android选择的布局?
假设我有一个在不同资源文件夹中具有三种不同布局的活动。例如: layout-land/my_act.xml layout-xlarge/my_act.xml layout-xlarge-land/my_act.xml Android在不同的设备和不同的位置中选择了其中之一。如何找到以编程方式选择的一个? Android是否有任何API将这些布局返回给程序? 编辑:Graham Borland的解决方案在我在评论中提到的某些情况下存在问题。

8
如何在Android中通过画布绘制圆?
我想按画布画圆。这是我的代码: [MyActivity.java]: public class MyActivity extends Activity { public void onCreate(Bundle savedInstanceState) { ... setContentView(new View(this,w,h)); } } [View.java]: public class View extends SurfaceView { public View(Context context, int w, int h) { super(context); Canvas grid = new Canvas(Bitmap.createBitmap(h,w, Bitmap.Config.ARGB_8888)); grid. drawColor(Color.WHITE); Paint paint = new Paint(); paint.setStyle(Paint.Style.FILL); grid.drawCircle(w/2, h/2 …


4
Android上的MongoDB
有谁知道MondgoDB如何在Android上运行。它在本地工作吗?您以后再复制数据吗?仅在Web后端上只能在线工作吗?
69 android  mongodb 

3
使用Intent.putExtra发送数组
我在活动A中有一个整数数组: int array[] = {1,2,3}; 我想将该变量发送到活动B,所以我创建了一个新的Intent并使用putExtra方法: Intent i = new Intent(A.this, B.class); i.putExtra("numbers", array); startActivity(i); 在活动BI中获取信息: Bundle extras = getIntent().getExtras(); int arrayB = extras.getInt("numbers"); 但这不是真正发送数组,我只是在arrayB上获得了值“ 0”。我一直在寻找一些例子,但没有发现任何事。

15
如何在NavigationView中为项目设置自定义字体?
使用new NavigationView,我们可以通过XML中的菜单资源来设置抽屉的项目。 这样,我们可以为每个项目设置类似 <item android:id="@+id/drawer_my_account" android:icon="@drawable/ic_my_account" android:title="@string/drawer_my_account" /> 但是现在,我想为抽屉中的每个项目设置一个自定义字体,而我找不到通过XML或Java代码实现自定义字体的方法。有办法吗?

4
解码后的位图字节大小?
我如何确定/计算位图的字节大小(使用BitmapFactory解码后)?我需要知道它占用了多少内存空间,因为我正在我的应用程序中进行内存缓存/管理。(文件大小不足,因为它们是jpg / png文件) 感谢您的任何解决方案! 更新:getRowBytes * getHeight可能会解决问题。.我将以这种方式实施,直到有人提出反对。
69 android  bitmap 

3
在onReceive BroadcastReceiver内部启动活动
我想用我的onReceive()方法开始一项活动。 package com.splashscreenactivity; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.telephony.SmsMessage; import android.widget.Toast; public class SMSReceiver extends BroadcastReceiver { public static String trigger_message = ""; @Override public void onReceive(Context context, Intent intent) { // ---get the SMS message passed in--- Bundle bundle = intent.getExtras(); SmsMessage[] msgs = null; …

14
错误:修复版本冲突(Google服务插件)
根据该SO线程,我知道存在版本冲突,但是在从Google获得新版本后问题仍然存在。 错误:任务':app:processDebugGoogleServices'的执行失败。请通过更新google-services插件的版本来解决版本冲突(有关最新版本的信息,请访问https://bintray.com/android/android-tools/com.google.gms.google-services/)。或将com.google.android.gms的版本更新为10.0.1。 我的build.gradle(模块:应用) .... dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) compile 'com.android.support:appcompat-v7:26.+' compile 'com.android.support.constraint:constraint-layout:1.0.2' testCompile 'junit:junit:4.12' compile 'com.google.firebase:firebase-messaging:10.0.1' compile 'com.google.android.gms:play-services-maps:11.0.4' compile 'com.google.android.gms:play-services-location:11.0.4' } apply plugin: 'com.google.gms.google-services' 现在需要进行哪些更改?



16
无法将Android应用上传到设备(过时的dexed jars)
我正在使用Android Studio开发此应用,今天,当我尝试将其上传到设备以进行测试时,我看到一个弹出窗口,其中说: 安装失败,因为该设备可能具有与当前版本不匹配的过时的dexed jar(dexopt错误)。为了继续,您必须卸载现有的应用程序。 警告:卸载将删除应用程序数据! 您要卸载现有的应用程序吗? 它提供了两个选项,确定或取消。单击确定后,“运行”选项卡中将显示以下消息: DEVICE SHELL COMMAND: pm uninstall my.bundle.id Unknown failure 该应用似乎已被卸载,在“管理应用”下没有任何痕迹。 我无法上传该应用。我尝试清理项目并重建,但没有成功。 我能做什么?

6
错误:com.android.builder.dexing.DexArchiveBuilderException:无法处理guava-21.0.jar Android 3.1开发者频道
在中更新依赖项版本后AndroidStudio3.1,我开始出现以下错误: Information:Gradle tasks [:app:assembleDebug] Error:com.android.builder.dexing.DexArchiveBuilderException: Failed to process C:\Users\Blabla\.gradle\caches\modules-2\files-2.1\com.google.guava\guava\21.0\3a3d111be1be1b745edfa7d91678a12d7ed38709\guava-21.0.jar Error:com.android.builder.dexing.DexArchiveBuilderException: Error while dexing. Error:com.android.tools.r8.ApiLevelException: Default interface methods are only supported starting with Android N (--min-api 24): java.util.Collection com.google.common.collect.BiMap.values() Error:Execution failed for task ':app:transformClassesWithDexBuilderForDebug'. > com.android.build.api.transform.TransformException: com.android.builder.dexing.DexArchiveBuilderException: com.android.builder.dexing.DexArchiveBuilderException: Failed to process C:\Users\Blabla\.gradle\caches\modules-2\files-2.1\com.google.guava\guava\21.0\3a3d111be1be1b745edfa7d91678a12d7ed38709\guava-21.0.jar Information:BUILD FAILED in 6s Information:4 errors Information:0 warnings Information:See …

5
隐藏并显示ViewPager的父Fragment时,ViewPager的Fragment的视图丢失
我一直在使用ViewPager和我自己的FragmentStatePagerAdapter看到一些奇怪的行为。 我的视图层次结构如下所示: -> (1) Fragment root view (RelativeLayout) -> (2) ViewPager -> (3) ViewPager's current fragment view 当负责片段根视图(1)的片段被隐藏(在片段事务中使用.hide())然后显示(与.show()一起)时,当前在ViewPager中显示的片段视图(3) )变为空,尽管该片段仍然存在。基本上,我的ViewPager变得完全空白/透明。 我发现解决此问题的唯一方法是致电 int current = myViewPager.getCurrentItem(); myViewPager.setAdapter(myAdapter); myViewPager.setCurrentItem(current); 显示父片段之后。这会触发视图重新创建并出现在屏幕上。不幸的是,这偶尔会导致处理寻呼机适配器的异常,该适配器unregisterDataSetObserver()在旧的观察器上调用两次。 有一个更好的方法吗?我想我要问的是: 隐藏ViewPager的父片段时,为什么ViewPager中的片段视图被破坏? 更新:当应用程序“最小化”然后“恢复”时(通过按下Home Action键然后返回),也会发生这种情况。 根据请求,这是我的寻呼机适配器类: public class MyInfoSlidePagerAdapter extends FragmentStatePagerAdapter { private ArrayList<MyInfo> infos = new ArrayList<MyInfo>(); public MyInfoSlidePagerAdapter (FragmentManager fm) { super(fm); …

12
移动设备上的Twitter Bootstrap模态
引导程序模式在Android和iOS上无法正常工作。问题跟踪器已确认问题,但未提供有效的解决方案: 2.0中的模式在移动设备上已损坏。 2.0中的模态窗口无法正确定位 屏幕变暗,但模态本身在视口中不可见。可以在页面顶部找到它。当您向下滚动页面时,会发生此问题。 这是bootstrap-sensitive.css的相关部分: .modal { position:fixed; top:50%; left:50%; z-index:1050; max-height:500px; overflow:auto; width:560px; background-color:#fff; border:1px solid #999; -webkit-border-radius:6px; -moz-border-radius:6px; border-radius:6px; -webkit-box-shadow:0 3px 7px rgba(0, 0, 0, 0.3); -moz-box-shadow:0 3px 7px rgba(0, 0, 0, 0.3); box-shadow:0 3px 7px rgba(0, 0, 0, 0.3); -webkit-background-clip:padding-box; -moz-background-clip:padding-box; background-clip:padding-box; margin:-250px 0 0 -280px; } …

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.