我尝试了以下命令,它在几个设备上运行良好.
adb shell getprop | grep abi
Run Code Online (Sandbox Code Playgroud)
此命令无法获取某些设备的ARM处理器版本.有没有其他方法可以找出我的设备运行的ARM处理器版本?
谢谢
我是Gradle构建系统的新手,我有一个库项目,其中包含Retrofit,okhttp等依赖项.
我编译了我的项目并创建了一个aar文件.我创建了一个虚拟项目,并将我的库添加为依赖项.
现在,如果我不在我的虚拟应用程序的build.gradle文件中添加Retrofit和okhttp作为依赖项,那么我的应用程序会因类未找到异常而崩溃.
我的问题是:由于库aar文件已经包含Retrofit和okhttp作为依赖,那么为什么我还需要在dummy app的build.gradle文件中显式添加它们呢?有解决方法吗?
这是我的库build.gradle
apply plugin: 'com.android.library'
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.+'
}
}
allprojects {
repositories {
jcenter()
}
}
android {
compileSdkVersion 22
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 14
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.+'
compile 'com.android.support:recyclerview-v7:21.+'
compile 'com.android.support:cardview-v7:21.+'
compile 'com.google.android.gms:play-services:6.5.87'
compile 'com.squareup.okhttp:okhttp:2.2.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用命令行运行android instrumentation Junit测试.我正在使用以下命令,它正在启动测试权限.
adb shell am instrument -w com.android.foo/android.test.InstrumentationTestRunner
Run Code Online (Sandbox Code Playgroud)
我的android项目包有以下java源文件(按字母顺序)
com.android.foo
ActivityTest
ContactsTest
LaunchTest
SendTest
当我使用上面提到的命令运行测试时,测试首先开始执行ActivityTest,依此类推.这不是我想要的,我希望它首先执行LaunchTest,然后是ContactTest,SendTest和ActivityTest.我试过用
adb shell am instrument -w -e class com.android.foo.LaunchTest,com.android.foo.ContactTest com.android.foo/android.test.InstrumentationTestRunner
Run Code Online (Sandbox Code Playgroud)
但它给我一个错误可能是因为我没有在我的代码中使用TestCase类,而是我的LaunchTest和其他人扩展了ActivityInstrumentationTestCase2.
任何帮助表示赞赏.
我正在使用Google地方自动填充API.我的应用程序有一个自动填充文本视图.当我按照这里的例子时,一切都很好.
唯一问题是我将LatLng界限设置为Mountain View的界限.
private static final LatLngBounds BOUNDS_MOUNTAIN_VIEW = new LatLngBounds(
new LatLng(37.398160, -122.180831), new LatLng(37.430610, -121.972090));
Run Code Online (Sandbox Code Playgroud)
我的GoogleApiClient
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addApi(Places.GEO_DATA_API)
.build();
Run Code Online (Sandbox Code Playgroud)
当我尝试输入新奥尔良地址时,我必须键入很多内容,这对于任何超出CA的用户来说都不是一个好的体验.是否有更好的方法根据当前位置设置LatLng边界,而不需要位置权限或精确位置位置.我假设这不是Places API的限制,而只是我有限的知识.
提前致谢.
我是Retrofit的新手并尝试使用Retrofit发出POST请求.我的POST请求有一个复杂的JSON正文,如下所示:
负载:
{
"user": {
"personal_info": {
"first_name": "Walter",
"last_name": "White",
"date_of_birth": "1972-01-03 00:00:00 PST"
},
"address_info": {
"address_1": "308 NEGRA ARROYO LANE",
"address_2": "#",
"city": "ALBUQUERQUE",
"state": "NM",
"zip_code": "87104"
},
"contact_info": {
"email": "wwhite@test.com",
"telephone": "88888888888",
"telephone_type_id": 1
},
"employment_info": {
"employer_name": "SELF",
"employment_status_id": 7,
"annual_income": 9000000000000000,
"monthly_income": 750000000000,
"employment_start_year": 0,
"employment_start_month": 0
}
}
}
Run Code Online (Sandbox Code Playgroud)
我将接口定义为
@POST("/users")
void registerUser(@Body User User, Callback<User> cb);
Run Code Online (Sandbox Code Playgroud)
我不确定我的User类应该是什么样子,我希望有效负载与上面提到的相同,到目前为止,我的User类为
public class User {
@SerializedName("personal_info")
private PersonalInfo personalInfo;
@SerializedName("address_info")
private AddressInfo addressInfo;
@SerializedName("contact_info") …Run Code Online (Sandbox Code Playgroud) 我的广播接收器侦听WiFi ssid更改,如果ssid更改,则返回布尔WifiChanged true.我在另一个活动中检查此布尔值,该活动根据返回的值更改列表,无论是真还是假.默认布尔值为假.
我故意改变wifi应该触发广播接收器将布尔值返回到true并相应地设置列表但实际发生的是我的列表基于布尔值false改变,因为广播接收器需要一段时间才能返回值.在下面的日志中,您可以看到布尔值为false,并且在0.58秒后大约ssid发生变化.到那时为时已晚
08-08 16:43:54.487: D/PlayerManager(20733): Did Wi-Fi Changed: false
|
|
|
08-08 16:43:55.047: V/ConnectionChangeReceiver(20733): onReceive(Context context, Intent intent)
08-08 16:43:55.077: D/ConnectionChangeReceiver(20733): ssid changed from s_ssid="Walter_Meth_Lab" to newSsid="Kings_Landing"
Run Code Online (Sandbox Code Playgroud)
这是我的OnReceive()
public class ConnectionChangeReceiver extends BroadcastReceiver {
private static final String TAG = "ConnectionChangeReceiver";
private static String s_ssid = null;
private static String s_ipAddress = null;
private static String mNetworkType;
private static ConnectionChangeReceiver sInstance;
private ConnectionChangeListener mConnectionChangeListener;
private boolean mHasWifiChanged;
public static ConnectionChangeReceiver getInstance() {
Log.v(TAG, "getInstance()");
synchronized (ConnectionChangeReceiver.class) { …Run Code Online (Sandbox Code Playgroud) 我试图找出一种方法来阻止Retrofit编码我传递给POST请求的电子邮件地址.这是我的POST界面
@POST("/security/oauth/token")
@FormUrlEncoded
void getAccessToken(@Field("client_id") String clientId,
@Field("client_secret") String clientSecret,
@Field("username") String username,
@Field("password") String password,
@Field("grant_type") String grantType, Callback<AccessToken> cb);
Run Code Online (Sandbox Code Playgroud)
当我发出请求时,Retrofit将这些字段发送为
client_id=test&client_secret=cajcckkcaaa&username=androidtest12%40gmail.com&password=Password23&grant_type=password
Run Code Online (Sandbox Code Playgroud)
这里的罪魁祸首是电子邮件地址,从androidtest12@gmail.com更改为androidtest12%40gmail.com导致服务器错误.
在此先感谢您的帮助.
搜索API以String格式返回日期,我想将该日期与当前日期进行比较并执行某些操作.我创建了一个日期对象并对其进行了解析,但在进行比较时仍然出现错误.
Calendar currentDate = Calendar.getInstance();
long dateNow = currentDate.getTimeInMillis();
String eventDate = meta.getString("startDate"); //This is the string API returns
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd kk:mm:ss.SSS");
Date date = formatter.parse(eventDate);
long modifiedDate= date.getTime();
if (dateNow.compareTo(modifiedDate)>0) {
//Do Something
}
Run Code Online (Sandbox Code Playgroud)
我得到的错误是:
Cannot invoke compareTo(long) on the primitive type long
Run Code Online (Sandbox Code Playgroud)
谢谢.