有没有什么方法可以在我的ndk appliation中传递/获取android上下文的对象.我想SharedPreferences
通过jni接口在我的ndk应用程序中使用.要获得一个实例SharedPreferences
对象,我需要调用getSharedPreferences()
的Context
对象.但我无法访问上下文对象.
要么
如何从NDK读取和写入xml文件?
任何指针将不胜感激.
有没有人尝试过Android UITesting
框架UIAutomator
?当我使用类UiScrollabl
"找到在一些物体滚动的物体,它不能找到对象,如果的长度滚动对象过长(需刷卡两次找到它),像是'开发人员选项’ "设置"应用.有没有人有同样的问题?
从我所看到的,当UIAutomator脚本被编译成jar文件并使用adb shell命令运行时.我可以看到有一个-e debug命令行选项在启动之前等待调试器连接,但是如何将它从Eclipse连接到调试器以便我可以调试我的UI Automator脚本?
是否可以在api <18上使用UIautomator?自动测试的主要目的是回归测试,并且还应测试具有android 4.1,4.2的设备.也许可以使用低于2.0的UIautomator库版本,但我无法找到有关以前版本的任何信息.
HttpClient在目标23中已弃用,所以我仍然希望在我的项目中使用httpClient,因此我在gradle文件中添加了以下依赖项org.apache.http.legacy,重建项目后,我收到以下错误.
错误:(6,0)未找到Gradle DSL方法:'useLibrary()'可能的原因:
项目"开发"可能正在使用不包含该方法的Gradle版本.Gradle设置 构建文件可能缺少Gradle插件.应用Gradle插件
我的gradle文件是
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "22.0.1"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.android.mobile.test"
minSdkVersion 15
targetSdkVersion 24
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
lintOptions{
abortOnError false
}
}
dependencies {
compile project(':library')
compile 'com.google.android.gms:play-services:+'
compile files('FlurryAnalytics-5.5.0.jar')
compile files('HockeySDK-3.5.0.jar')
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.+'
}
Run Code Online (Sandbox Code Playgroud)
root build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies …
Run Code Online (Sandbox Code Playgroud) 众所周知,例如,我们无法res
在运行时更改文件夹值和文件,
我正在开发一个应用程序,其中我们支持25种以上的语言,由于这些字符串文件,APK的大小急剧增加,我们非常关注APK的大小,因此我们不想将所有这些string.xml
文件都保留在本地在项目中(内部apk)。
我们现在的想法是,我们将只保留英语string.xml
里res
,和所有其他区域设置string.xml
应该从需求的基础上推出的应用服务器下载。
因此,我们计划创建自己的getResource( key, currentLocale)
,然后从将从服务器下载的XML(或文本)文件中读取该文件。
请提出任何更好的主意或解决方法,
谢谢支持
是否可以获取特定 View(或)的 Window 对象PopupWindow
?
我的应用程序是一个键盘,因此它是一个服务(一个InputMethodService
),而不是一个活动。因此我不能使用Activity.getWindow()
. 然而,它有视图,所以它大概也有一个窗口,不是吗?我怎样才能得到它?
提前致谢...
我想用指定的时间长按指定的点.不幸的是,没有像在课堂上长按一样的方法:UiDevice 我可能会编写自己的方法,如下所示:
private void longClick(int x, int y, long time) {
android.graphics.Point point = new android.graphics.Point(x, y);
android.graphics.Point[] points = new android.graphics.Point[2];
points[0] = point;
points[1] = point;
getUiDevice().swipe(points, time / 5); // according to documentation, each step lasts 5ms
}
Run Code Online (Sandbox Code Playgroud)
或使用反射并调用longTap:
private void longClick(int x, int y) {
Field mUiAutomationBridgeField = getUiDevice().getClass().getDeclaredField("mUiAutomationBridge");
mUiAutomationBridgeField.setAccessible(true);
Object mUiAutomationBridge = mUiAutomationBridgeField.get(getUiDevice());
Field mInteractionControllerField = mUiAutomationBridge.getClass().getDeclaredField("mInteractionController");
mInteractionControllerField.setAccessible(true);
Object mInteractionController = mInteractionControllerField.get(mUiAutomationBridge);
Method longTap = mInteractionController.getClass().getDeclaredMethod("longTap", int.class, int.class);
longTap.setAccessible(true);
longTap.invoke(mInteractionController, x, y);
}
Run Code Online (Sandbox Code Playgroud)
然而,它不是满意的解决方案,任何想法如何做得更好的方式?他们为什么错过这种方法?
我getMaxLines()
在冰淇淋三明治Android 4.0.3版本上使用Texview方法时遇到崩溃日志,
所以我得到的真正问题是,我的应用程序运行较低的sdk,它没有这个getMaxLines()方法.
如何消除此崩溃.我没有找到任何替代方法
java.lang.NoSuchMethodError: android.widget.TextView.getMaxLines
at com.text.mobile.new.adapters.ServiceListAdapter.onBindViewHolder(ServiceListAdapter.java:232)
at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:5277)
at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:5310)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4568)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4461)
at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:1962)
at android.support.v7.widget.GridLayoutManager.layoutChunk(GridLayoutManager.java:438)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1334)
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:563)
at android.support.v7.widget.GridLayoutManager.onLayoutChildren(GridLayoutManager.java:171)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2847)
at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3145)
at android.view.View.layout(View.java:11278)
at android.view.ViewGroup.layout(ViewGroup.java:4224)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:925)
at android.view.View.layout(View.java:11278)
at android.view.ViewGroup.layout(ViewGroup.java:4224)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:925)
at android.view.View.layout(View.java:11278)
at android.view.ViewGroup.layout(ViewGroup.java:4224)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1628)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1486)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1399)
at android.view.View.layout(View.java:11278)
at android.view.ViewGroup.layout(ViewGroup.java:4224)
at android.widget.FrameLayout.onLayout(FrameLayout.java:431)
at android.view.View.layout(View.java:11278)
at android.view.ViewGroup.layout(ViewGroup.java:4224)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1628)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1486)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1399)
at android.view.View.layout(View.java:11278)
at android.view.ViewGroup.layout(ViewGroup.java:4224)
at android.widget.FrameLayout.onLayout(FrameLayout.java:431)
at android.view.View.layout(View.java:11278)
at android.view.ViewGroup.layout(ViewGroup.java:4224) …
Run Code Online (Sandbox Code Playgroud) 我正在使用TabLayout
在新的Android小部件包中引入android.support.design.widget.TabLayout
昨天我的代码运行正常,现在我今天开始使用我的计算机,并尝试重新构建项目,现在Compiler先生说下面的错误
Error:(22) No resource identifier found for attribute 'eleMode' in package 'android'
Error:(22) No resource identifier found for attribute 'tabGrvation' in package 'android.com.hsc.yatra'
Error:(22) No resource identifier found for attribute 'tabavity' in package 'android.com.hsc.yatra'
Run Code Online (Sandbox Code Playgroud)
请指导我哪里不对?所以我的编译器很开心,然后编译项目.
这是我的XML,其中发生了原始错误
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<!--<android.support.v7.widget.Toolbar-->
<!--android:id="@+id/toolbar"-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="?attr/actionBarSize"-->
<!--android:background="?attr/colorPrimary"-->
<!--app:layout_scrollFlags="scroll|enterAlways"-->
<!--app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />-->
<include layout="@layout/toolbar_searched_bus">
</include>
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:eleMode="fixed"
app:tabGrvation="2dp"
app:tabavity="fill" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)