Questions tagged «android»

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

30
无法在Android Studio中调试应用
我正在Android Studio中制作一个应用,现在尝试通过adb对其进行调试。当我单击Android一词和底部栏上的徽标时,logcat出现并识别出我的设备。然后我看到了: 我需要对我的应用程序执行什么操作才能使其“可调试”? FYI之前是在Eclipse中开发此应用的,而adb可以正常工作。


4
Android:如何在模拟器中使用网络摄像头?
我通过在AVD Manager中将前置摄像头设置为“ webcam0”将摄像头连接到仿真器。启动模拟器的相机应用程序时,出现错误 CameraService::connect X (pid 702) rejected (invalid cameraId 0). 这是Android源代码的相关部分: sp<ICamera> CameraService::connect( const sp<ICameraClient>& cameraClient, int cameraId) { int callingPid = getCallingPid(); [...] if (cameraId < 0 || cameraId >= mNumberOfCameras) { LOGE("CameraService::connect X (pid %d) rejected (invalid cameraId %d).", callingPid, cameraId); return NULL; } [...] } 由于只有1个摄像头,因此已为网络摄像头正确分配了ID …
81 android 


3
Android中的Moshi vs Gson [关闭]
已关闭。这个问题是基于观点的。它当前不接受答案。 想改善这个问题吗?更新问题,以便通过编辑此帖子以事实和引用的形式回答。 上个月关闭。 改善这个问题 我正在决定是使用Square还是Gson的Moshi来序列化和反序列化模型数据。 我一直不喜欢Gson的一件事是我认为它使用反射功能,而这在Android上可能会很慢?莫希也使用反射吗? Moshi vs Gson有哪些优缺点? 我认为它们相似。例如,该语句创建一个typeAdapter: class CardAdapter { @ToJson String toJson(Card card) { return card.rank + card.suit.name().substring(0, 1); } @FromJson Card fromJson(String card) { if (card.length() != 2) throw new JsonDataException("Unknown card: " + card); char rank = card.charAt(0); switch (card.charAt(1)) { case 'C': return …

9
在Android中从Firebase发送通知时没有通知声音
我正在从Firebase向我的Android应用程序发送推送通知。但是,当我的应用程序处于后台firebase时,不会调用onMessageReceived方法,firebase会将通知发送给系统以在系统任务栏中显示通知。通知出现在系统托盘中,但是没有声音发出通知,即使我在系统设置中允许我的应用程序发出通知声音。 从Firebase收到通知时我该怎么做以播放通知声音。 这就是我从Firebase向我的应用程序Blogpost链接发送通知的方式。 如何在Android应用程序中添加Firebase

4
如何从Windows(v10)完全卸载Android Studio?
我已经看过这个问题了。但这是针对Mac OS的。我正在使用Windows。每当我创建一个新项目或尝试build/rebuild该项目时,它都会冻结!!我已经安装了最新版本(9/10/2016)。但是情况越来越糟。我想完全删除它并安装它,就像我第一次安装它一样。任何帮助将不胜感激。

8
MaterialComponents主题警报对话框按钮
最近,我从支持库切换到com.google.android.material:material:1.0.0 但是现在我有一个问题,在此页面中有一条注释https://github.com/material-components/material-components-android/blob/master/docs/getting-started.md 注意:使用“材料组件”主题可以启用自定义视图充气器,该充气器将默认组件替换为其“材料”对应的组件。当前,这仅用MaterialButton替换Button XML组件。 我正在使用的主题 Theme.MaterialComponents.Light.NoActionBar 完全按照该注释中的说明进行操作,它将AlertDialog Buttons替换为MaterialButtons,但是问题是默认情况下MaterialButtons是彩色背景,现在这些按钮如下所示: 如何使它们再次变得无边界和无背景? PS我正在使用警报生成器来创建警报对话框: android.app.AlertDialog.Builder

12
Logcat崩溃并显示错误:意外的EOF
我正在进行一些冗长的计算,但很晚才出问题。我尝试使用断点,但到目前为止没有成功。所以我进入了一个循环Log.d来监视... 但是很快,Logcat崩溃了: 02-08 16:35:42.820 2936-3402/com.nohkumado.geneticsolving.full D/BaseC: norm:BC sq:49.0 dis:0.0 con:50.0/BC sq:56.0 dis:4.0 con:94.0=1.4069148936170213 read: unexpected EOF! --------- beginning of crash 我需要重新启动Studio才能使Logcat重新运行。 我查看了是否可以找到Logcat缓冲区大小的一些设置,但是到目前为止,我什么都没找到。该怎么办?

12
当Android N Display Size设置为大于Small时,“画布:试图绘制太大的位图”
我有一个发布的应用程序,当新引入的Display sizeOS设置设置为太大的值时,在Android N上启动时崩溃。 当我查看logcat时,会看到以下消息: java.lang.RuntimeException: Canvas: trying to draw too large(106,975,232 bytes) bitmap. 我已经在我的第一个Activity中将问题追溯到ImageView,该ImageView显示了一个不错的大背景图像。有问题的图像是2048x1066,位于我的通用drawables目录中,因此无论密度如何,都将使用该图像。 Display size设置为时,一切正常Small。但是当我转到时Default,它停止工作。然后,如果我将图像换成较小的图像,它将在处工作Default,但如果升至Large,它将再次停止工作。 我的猜测是,Display size向上调整会使您的设备像具有更高像素密度的物理上较小的设备那样工作。但是我不明白我应该在这里做什么。如果我以逐渐减小的分辨率输入逐渐减小的图像,则在大尺寸显示器上看起来效果不佳。还是我不明白某事? 任何指针将不胜感激。

4
带有圆角的进度栏?
我正在尝试实现此进度栏设计: 我目前的代码产生此: 这是代码: <item android:id="@android:id/background"> <shape> <corners android:radius="8dp"/> <solid android:color="@color/dirtyWhite"/> </shape> </item> <item android:id="@android:id/progress"> <clip> <shape> <corners android:radius="8dp"/> <solid android:color="@color/colorPrimaryDark"/> </shape> </clip> </item> 我的进度条: <ProgressBar android:id="@+id/activeProgress" style="?android:attr/progressBarStyleHorizontal" android:layout_width="300dp" android:layout_height="wrap_content" android:layout_weight="1" android:progress="10" android:progressDrawable="@drawable/rounded_corners_progress_bar"/> 我尝试添加<size>的属性<shape>中<clip,以使进度外形有点小,但没有奏效。另外,进度条是扁平的,我想按照设计弯曲。为了实现设计,我需要更改什么?

13
此版本使用了不推荐使用的Gradle功能,使其与Gradle 5.0不兼容
我有一个失败的失败: ..."Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0." 案例说明: 将以下库附加到项目代码库: APP / build.gradle //(Required) Writing and executing Unit Tests on the JUnit Platform testImplementation "org.junit.jupiter:junit-jupiter-api:5.2.0" testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.2.0" // (Optional) If you need "Parameterized Tests" testImplementation "org.junit.jupiter:junit-jupiter-params:5.2.0" // (Optional) If you also have JUnit …


9
如何以编程方式从Facebook SDK 3.0注销而不使用Facebook登录/注销按钮?
标题说明了一切。我正在使用自定义按钮来获取用户的Facebook信息(用于“注册”目的)。但是,我不希望该应用程序记住上次注册的用户,也不要记住当前通过Facebook本机应用程序登录的人。我希望Facebook登录活动每次都弹出。这就是为什么我要以编程方式注销以前的所有用户。 我怎样才能做到这一点?这是我进行登录的方式: private void signInWithFacebook() { SessionTracker sessionTracker = new SessionTracker(getBaseContext(), new StatusCallback() { @Override public void call(Session session, SessionState state, Exception exception) { } }, null, false); String applicationId = Utility.getMetadataApplicationId(getBaseContext()); mCurrentSession = sessionTracker.getSession(); if (mCurrentSession == null || mCurrentSession.getState().isClosed()) { sessionTracker.setSession(null); Session session = new Session.Builder(getBaseContext()).setApplicationId(applicationId).build(); Session.setActiveSession(session); mCurrentSession …

4
使用TextInputLayout时无法解析资源@ id / visible
无法解析资源@id/visible使用时TextInputLayout上appcompat-v7:25.x.x 尝试了以下这些步骤,但问题仍然存在: 重建项目 清理和重建项目 清除缓存并重新启动Android Studio 以下是布局文件中的代码。 <android.support.design.widget.TextInputLayout android:id="@+id/tilFirstName" android:layout_width="match_parent" android:layout_height="wrap_content"> <android.support.design.widget.TextInputEditText android:id="@+id/etFirstName" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="@string/first_name" android:inputType="textPersonName"/> </android.support.design.widget.TextInputLayout> 以下是Android Studio中显示的消息 渲染问题。 无法解析资源 @id/visible 提示:尝试刷新布局。 注意:@id/visible代码中不存在。

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.