我需要用Android 4.0.3测试我的Android应用程序,但我无法用这个Android版本创建一个模拟器.请查看以下截图以获取更多详细信息:
已经尝试过没有运气了:
我该如何解决这个问题?
编辑:
正如BrentM所建议的那样,我尝试使用android命令行工具创建它.它已成功创建,但当我尝试从Android Studio编辑它时,它会出错:指定的图像文件必须是有效的图像文件.
系统中图像文件的地址:/ Android/Sdk/system-images/android-15/x86
android android-emulator android-studio android-4.0.3-ice-cream-sandwich
我有一个服务,如果用户改变了他的位置,它会发出通知。我希望此服务继续运行,直到用户在应用程序管理器中明确强制停止我的应用程序。我使用了以下方法:
Intent intent1 = new Intent(context, LocationService2.class);
PendingIntent contentIntent = PendingIntent.getService(context, 0, intent1, 0);
AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime(),2*60000, contentIntent);
Run Code Online (Sandbox Code Playgroud)
服务等级:
public class LocationService2 extends Service implements GoogleApiClient.ConnectionCallbacks,GoogleApiClient.OnConnectionFailedListener {
private GoogleApiClient mGoogleApiClient;
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.v("TAG", "STARTLS");
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API)
.build();
mGoogleApiClient.connect();
return START_STICKY;
}
@Override
public void onConnected(Bundle bundle) {
Log.i(TAG, "Location services connected.");
Location location = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);
// Use this location to give notification if …Run Code Online (Sandbox Code Playgroud) 我有一个约束布局,其中一个文本视图位于左侧,另一个文本视图位于右侧。我希望正确的文本视图与末尾对齐。右侧文本视图也应该能够占用左侧的可用空间。如果空间不够,它应该在末端呈椭圆形。
我已经尝试使用以下 xml 代码:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:padding="@dimen/dimen_16dp">
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:text="Title"
android:textStyle="bold"
android:layout_marginEnd="@dimen/dimen_24dp"/>
<TextView
android:id="@+id/subtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:ellipsize="end"
android:maxLines="1"
android:text="Subtitle"/>
</androidx.constraintlayout.widget.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)
这对于右侧文本视图中的小文本非常有效。但是,如果右侧文本视图中的文本很大,它会与左侧文本视图重叠。我尝试添加app:layout_constraintStart_toEndOf="@id/title"到正确的文本视图,但这会导致两个问题:
如何在不将父布局更改为线性布局的情况下实现这一点?
当我将图像放在drawable文件夹中时,我OutOfMemoryError在设置图像资源时得到了,但是在将相同的图像移动到drawable-nodpi文件夹后解决了错误.将图像移动到drawable-nodpi文件夹时如何解决错误?