Questions tagged «android»

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

12
如何使用后退按钮之类的按钮关闭当前片段?
我尝试使用Imagebutton关闭当前片段。 我在Fragment-A中,当我单击按钮时它将变为Fragment-B。 当我单击“片段B”处的按钮时,它将转到“片段C”并关闭“片段B”。 如果单击Fragment-C的后退按钮,它将返回到Fragment-A。 我尝试的代码如下所示 camera_album = (ImageButton) view.findViewById(R.id.camera_album); camera_album.setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { closefragment(); Fragment fragment = FileBrowserFragment.newInstance(null, null, null) ; MainActivity.addFragment(LocalFileBrowserFragment.this, fragment) ; } }); private void closefragment() { getActivity().getFragmentManager().beginTransaction().remove(this).commit(); } 当我单击片段B处的后退按钮时,它变为片段C。 但是,当我单击Fragment-C上的后退按钮时,它不会返回到Fragment-A。它回到空的背景。如果要返回至Fragment-A,则必须再次单击“后退”按钮。 所以,似乎没有关闭当前片段完整。 如何完成当前片段,如Android的“后退”按钮?


9
无法获得WRITE_SETTINGS权限
当我在Android M Preview 3上的目标API为23时,我似乎无法获得Manifest.permission.WRITE_SETTTINGS权限。 requestPermissions(new String[]{Manifest.permission.WRITE_SETTINGS}, 101); 请求权限不会打开我期望的对话框,但是如果我在没有此权限的情况下进行以下通话, RingtoneManager.setActualDefaultRingtoneUri(activity, RingtoneManager.TYPE_RINGTONE, ringUri); 除非我没有许可,否则电话会打来。 我不确定从这里去哪里。是否有适用于23的新铃声API?还是此权限更改只是使任何非系统应用程序都无法更改铃声?

10
具有超过3个项目的BottomNavigationView:标签标题隐藏
我将BottomNavigationView与Android Support Desing Library 25一起使用。但是当我切换选项卡时,另一个选项卡的标题被隐藏了。但是实际的底部导航视图没有隐藏问题。但是我的隐藏了。 但我希望它看起来像那样。有什么想法吗?我想念什么? 这是我的代码: activity_main.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/activity_main" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.yunus.ototakip.MainActivity"> <FrameLayout android:id="@+id/main_container" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_above="@+id/bottom_navigation" android:layout_alignParentTop="true"> </FrameLayout> <android.support.design.widget.BottomNavigationView android:id="@+id/bottom_navigation" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" app:itemBackground="@color/colorPrimary" app:itemIconTint="@color/beyaz" app:itemTextColor="@color/beyaz" app:menu="@menu/bottombar_menu" /> bottom_bar_menu.xml <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <item android:id="@+id/bb_menu_arac" android:enabled="true" android:icon="@drawable/icon_car" android:title="@string/araclarim" app:showAsAction="ifRoom" /> <item android:id="@+id/bb_menu_yakin" android:enabled="true" android:icon="@drawable/icon_yer" android:title="@string/yakinimdakiler" app:showAsAction="ifRoom" …

14
AlarmManager在多个设备中不起作用
我的应用程序使用AlarmManager,并且从4年前就开始运行。但是我注意到某些设备开始出现故障。 我非常确定代码是正确的(因为我在装有Doze的设备上使用WakefulBroadcastReceiver和setExactAndAllowWhileIdle),因为它可以在Nexus设备上正常运行,但是在某些制造商的设备(华为,小米等)中却无法使用。 例如,华为设备具有一种可杀死应用程序的电池管理器,当应用程序被终止时,计划的警报将被取消。因此,在华为电池管理器中将应用设置为“受保护”即可解决该问题。 但是最近我注意到它不能在更多设备上使用:小米,三星(也许与新的“智能管理器”有关?)……这种行为似乎正在成为一种标准:杀死后台应用程序。 有人知道吗?有什么方法可以确保触发警报? 编辑:此问题是由不同制造商添加的“节电器”引起的。更多信息在这里:https : //dontkillmyapp.com/

30
失败[INSTALL_FAILED_INVALID_APK]
当我单击运行一个我刚刚在Android Studio 0.2.10中创建的项目并选择我的Android(通过USB连接并通过USB调试打开)时,出现此错误: Waiting for device. Target device: 0123456789ABCDEF Uploading file local path: /Users/Rui/AndroidStudioProjects/FirstAppProject/FirstApp/build/apk/FirstApp-debug-unaligned.apk remote path: /data/local/tmp/rui.firstapp Installing rui.firstapp DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/rui.firstapp" pkg: /data/local/tmp/rui.firstapp Failure [INSTALL_FAILED_INVALID_APK] 有什么想法吗?

30
Flutter.io Android许可证状态未知
[!] Android工具链-为Android设备开发(Android SDK 27.0.3) •Android SDK a .. \ Android \ sdk•未配置Android NDK位置(可选;对本机性能分析支持很有用)•平台android-27,构建工具27.0.3•Java二进制文件位于:C:\ Program Files \ Android \ Android Studio \ jre \ bin \ java•Java版本OpenJDK运行时环境(内部版本1.8.0_152-release-1024-b02)X And​​roid许可证状态未知。 运行Flutter doctor时,Android Sdk出现错误,尽管我仍然可以在设备上构建/运行。我只是对如何解决此问题感到好奇。我相信我已经下载了android sdk的最新版本,不确定发生了什么,因为上周我没有这个问题。 新刊 遵循注释中的几个可能的修复程序之后,它导致了一个新问题。我安装了较新版本的android sdk P,8和7,以及新的jdk10。显然仍然没有足够的更新。 C:\Flutter\flutter>flutter doctor --android-licenses A newer version of the Android SDK is required. To update, run: …
85 android  flutter 


3
为什么onKey()被调用两次?
我正在使用此代码: public boolean onKey(View v, int keyCode, KeyEvent event) { msg = (EditText)findViewById(R.id.msg); String message = msg.getText().toString(); if(keyCode == 66) { //It's hitting here twice. } return false; }; 谁能告诉我为什么在我按Enter键时它会被击中两次?
85 android 



26
Android Studio 3.0执行任务失败:无法合并dex
android studio在执行构建时出现以下构建错误: 错误:任务':app:transformDexArchiveWithExternalLibsDexMergerForDebug'的执行失败。java.lang.RuntimeException:java.lang.RuntimeException:com.android.builder.dexing.DexArchiveMergerException:无法合并dex” 我的app:build.gradle文件: apply plugin: 'com.android.application' android { compileSdkVersion 26 buildToolsVersion '26.0.2' defaultConfig { applicationId "com.pdroid.foodieschoice" minSdkVersion 16 targetSdkVersion 25 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude …

10
Android错误构建已签名的APK:未发现用于签名配置“ externalOverride”的keystore.jks
当我尝试构建签名APK时出现此错误。我最近升级到API 23,但此后成功生成了APK:s。我糊涂了。寻求帮助并建议如何解决此问题。这是错误 FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:validateExternalOverrideSigning'. > Keystore file /Users/me/Desktop/final apps/keystore.jks not found for signing config 'externalOverride'. * Try: Run with --stacktrace option to get the stack trace. Run with --info or -- debug option to get more log …

7
不推荐使用Android context.getResources.updateConfiguration()
就在最近的context.getResources()中。在Android API 25中已不建议使用updateConfiguration(),建议使用上下文。改为使用createConfigurationContext()。 有谁知道如何使用createConfigurationContext来覆盖android系统区域设置? 在此之前,可以通过: Configuration config = getBaseContext().getResources().getConfiguration(); config.setLocale(locale); context.getResources().updateConfiguration(config, context.getResources().getDisplayMetrics());


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.