Questions tagged «android»

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


6
如何解决“在APK META-INF / *中复制的重复文件”
我在一个商业android应用程序上工作。我还使用了一些使用不同许可类型许可的库,其中一些声明如下: 如果库中有带有归因说明的“ NOTICE”文件,则在分发时必须包括该NOTICE (例如,其中之一已获得Apache License 2.0的许可)。 有多个库。使用gradle或Android Studio进行构建时,出现以下构建错误: * What went wrong: Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'. > com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/license.txt 到目前为止,我在Internet和stackoverflow上找到的答案建议通过将build.gradle以下内容添加到文件中,将license.txt(notice.txt或其他可能会干扰到此的文件)从打包中删除: packagingOptions { exclude 'META-INF/DEPENDENCIES.txt' exclude 'META-INF/LICENSE.txt' exclude 'META-INF/NOTICE.txt' exclude 'META-INF/NOTICE' exclude 'META-INF/LICENSE' exclude 'META-INF/DEPENDENCIES' exclude 'META-INF/notice.txt' exclude 'META-INF/license.txt' exclude 'META-INF/dependencies.txt' exclude 'META-INF/LGPL2.1' } …
91 java  android  gradle 

2
收藏的内容未在Webview上正确显示
我正在开发语言词典应用程序。我将喜欢的单词保存到“首选项”中。XML文件中的“收藏夹”内容如下所示: <?xml version='1.0' encoding='utf-8' standalone='yes' ?> <map> <string name="history"> dict_name::160170::hi,dict_name::157140::he-man,dict_name::184774::jet,dict_name::34527::black </string> <string name="waitingTime"> 0 </string> <boolean name="saveFavourite" value="true" /> <string name="defaultDictionary"> dict_name </string> <string name="favourite"> dict_name::149271::go,dict_name::25481::back,dict_name::184774::jet </string> <boolean name="saveHistory" value="true" /> </map> 我使用以下代码将“收藏夹”内容加载到Web视图中: public class User extends Activity { private static final String FAVOURITE_TAG = "[MyDict - FavouriteView] "; private …
91 android  xml  webview 

1
使用Robolectric测试ViewPager(和CursorLoader)
有谁知道如何使用Robolectric测试以下设置? 包含ViewPager和使用CursorLoader加载数据的片段。 使用下面的代码,CursorLoader永远不会被推入视图分页器的适配器中。我被await()电话卡住了。 EventsFragmentTest.java: @RunWith(CustomRobolectricTestRunner.class) public class EventsFragmentTest extends AbstractDbAndUiDriver { // which element in the view pager we are testing private static final int TEST_INDEX = 0; protected SherlockFragmentActivity mActivity; protected EventsFragment_ mFragment; @Override @Before public void setUp() throws Exception { // create activity to hold the fragment this.mActivity …


15
Android中的MD5哈希
我有一个简单的android客户端,需要与一个简单的C#HTTP侦听器“对话”。我想通过在POST请求中传递用户名/密码来提供基本的身份验证级别。 MD5哈希在C#中是微不足道的,可以为我的需求提供足够的安全性,但是我似乎找不到在android端如何做到这一点。 编辑:只是为了解决有关MD5弱点的担忧-C#服务器在我的Android客户端用户的PC上运行。在许多情况下,他们将在自己的LAN上使用wi-fi访问服务器,但风险自负,他们可能选择从Internet访问服务器。服务器上的服务也需要使用MD5直通到我无法控制的第三方应用程序。

10
Android中使用SQLite的外键约束?在删除级联上
我有两个表:航迹和航路点,一个航迹可以有多个航路点,但是航路点仅分配给1条航迹。 在点表的方式中,我有一个名为“ trackidfk”的列,一旦创建了轨道,该列就会插入track_ID,但是我没有在此列上设置外键约束。 删除轨道时,我想删除分配的航点,这可能吗?我读过有关使用触发器的信息,但我认为Android不支持它们。 要创建航点表: public void onCreate(SQLiteDatabase db) { db.execSQL( "CREATE TABLE " + TABLE_NAME + " (" + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + LONGITUDE + " INTEGER," + LATITUDE + " INTEGER," + TIME + " INTEGER," + TRACK_ID_FK + " INTEGER" + " …

11
为什么我的android活动总是开始滚动到底部?
每当我开始此活动时,它总是从最低点开始-一直滚动到最低点。我没有在活动OnCreate(或任何与此相关的事情)中做任何我想更改滚动位置的奇怪操作。我尝试将焦点设置为最可聚焦的控件和scrollto方法,但是它们都不起作用。此外,我的其他活动都没有这个问题。这是布局: <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/scroll" android:layout_width="fill_parent" android:layout_height="wrap_content"> <LinearLayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/edit_refresh_update_header" android:textSize="18sp"/> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="\n" android:textSize="4sp"/> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Variable:" android:textSize="18sp"/> <Spinner android:id="@+id/edit_refresh_variables_spinner" android:layout_width="match_parent" android:layout_height="wrap_content"/> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="\n" android:textSize="4sp"/> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Network:" android:textSize="18sp"/> <RadioGroup android:id="@+id/widget1" android:layout_width="match_parent" android:layout_height="wrap_content" xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical"> <RadioButton android:text="Web" android:id="@+id/edit_refresh_update_rb_web" android:layout_width="wrap_content" android:layout_height="wrap_content" …
91 android  layout 

21
尝试在Android 5.0上使用RecyclerView时应用崩溃
我试图弄乱新的RecyclerView,并且每当尝试运行它时,我的应用程序立即崩溃。它为我提供了NullPointerException,用于尝试从中访问方法android.support.v7.widget.RecyclerView。我查看了其他帖子,发现大多数人都没有,compile 'com.android.support:recyclerview-v7:+'但是我尝试了一下,但完全没有帮助。目前还不确定要怎么做,我们将不胜感激。这里是错误日志:(我会发布图片,但我还没有10位代表) java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.widget.RecyclerView$LayoutManager.onMeasure(android.support.v7.widget.RecyclerView$Recycler, android.support.v7.widget.RecyclerView$State, int, int)' on a null object reference at android.support.v7.widget.RecyclerView.onMeasure(RecyclerView.java:1764) at android.view.View.measure(View.java:17430) at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:727) at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:463) at android.view.View.measure(View.java:17430) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463) at android.widget.FrameLayout.onMeasure(FrameLayout.java:430) at android.view.View.measure(View.java:17430) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463) at android.widget.FrameLayout.onMeasure(FrameLayout.java:430) at android.view.View.measure(View.java:17430) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436) at android.widget.LinearLayout.measureVertical(LinearLayout.java:722) at android.widget.LinearLayout.onMeasure(LinearLayout.java:613) at android.view.View.measure(View.java:17430) …

9
android-将图像保存到图库
我有一个带有图片库的应用,我希望用户可以将其保存到自己的库中。我创建了一个带有单个语音“保存”的选项菜单,但允许的问题是...如何将图像保存到图库中? 这是我的代码: @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle item selection switch (item.getItemId()) { case R.id.menuFinale: imgView.setDrawingCacheEnabled(true); Bitmap bitmap = imgView.getDrawingCache(); File root = Environment.getExternalStorageDirectory(); File file = new File(root.getAbsolutePath()+"/DCIM/Camera/img.jpg"); try { file.createNewFile(); FileOutputStream ostream = new FileOutputStream(file); bitmap.compress(CompressFormat.JPEG, 100, ostream); ostream.close(); } catch (Exception e) { e.printStackTrace(); } …

10
Android:可以显示视频缩略图吗?
我使用“库”对话框创建了一个视频录制应用程序。“库”对话框显示已录制视频的列表,其中每个项目均通过以下方式由图标,视频标题,标签和位置信息组成: 有谁知道是否可以用视频缩略图替换图标(单帧预览)? 谢谢!
91 android 


12
如何缩小代码-dex中的65k方法限制
我有一个相当大的Android应用程序,它依赖于许多图书馆项目。Android编译器对每个.dex文件有65536个方法的限制,我已经超过了这个数目。 达到方法限制时,基本上可以选择两种路径(至少我知道)。 1)缩小代码 2)构建多个dex文件(请参阅此博客文章) 我对两者进行了调查,试图找出导致我的方法计数过高的原因。Google Drive API的Guava依赖项占最大部分,超过12,000。Drive API v2的库总数超过23,000! 我想我的问题是,您认为我应该怎么做?我是否应该删除Google云端硬盘集成作为我的应用程序的功能?有没有一种缩小API的方法(是的,我使用proguard)?我是否应该走多dex路线(看起来很痛苦,尤其是与第三方API的交流)?

14
为什么Google Play商店说我的Android应用程序与我自己的设备不兼容?
我很犹豫地问这个问题,因为似乎很多人都遇到了类似的问题,但是我没有找到能够解决我的特定情况的解决方案。 我开发了一个Android应用程序(链接到实际应用程序),并将其上传到Play商店。Play商店说 "This app is incompatible with your XT Mobile Network HTC HTC Wildfire S A510b." 当然,这就是我开发应用程序的手机,因此它应该兼容。有些使用其他设备的人说它报告兼容,而其他人则说它不兼容,但是我找不到趋势。(显然,我对使用Android设备的人知之甚少。) 我尝试了以下方法: res/raw按照此答案的建议将大文件移出目录。唯一的文件是一个约700 kB的文本文件,但我将其移至assets/没有明显变化的地方。 添加以下两个功能断言: <uses-feature android:name="android.hardware.faketouch" /> <uses-feature android:name="android.hardware.touchscreen" android:required="false" /> 认为我的手机可能并不声称支持通常的android.hardware.touchscreen功能,但又没有明显变化。 将APK上传到Play商店时,该android.hardware.faketouch功能报告为唯一处于活动状态的过滤器。 以下是输出aapt dump badging bin/NZSLDict-release.apk: package: name='com.hewgill.android.nzsldict' versionCode='3' versionName='1.0.2' sdkVersion:'4' targetSdkVersion:'4' uses-feature:'android.hardware.faketouch' uses-feature-not-required:'android.hardware.touchscreen' application-label:'NZSL Dictionary' application-icon-160:'res/drawable/icon.png' application: label='NZSL Dictionary' icon='res/drawable/icon.png' launchable-activity: …

2
在Android中从C ++调用Java方法
我试图从C ++获得一个简单的Java方法调用,而Java调用本机方法。这是Java代码: public class MainActivity extends Activity { private static String LIB_NAME = "name"; static { System.loadLibrary(LIB_NAME); } /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); TextView tv = (TextView) findViewById(R.id.textview); tv.setText(this.getJniString()); } public void messageMe(String text) { System.out.println(text); } public …

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.