小编Aka*_*iya的帖子

预览在camera2 apis中延伸

以下是在camera2 apis中使用纹理视图时的屏幕截图.在全屏幕中,预览会拉伸,但在使用较低分辨率(第二张图像)时可以使用.如何在不拉伸的情况下全屏使用此预览.

android screen-resolution android-camera android-textureview android-camera2

15
推荐指数
1
解决办法
1663
查看次数

未选中调用方法作为原始类型的成员

以下警告显示在我的项目中 -

未选中调用'getWeatherData(T,Boolean,String)'作为原始类型'IWeatherCallbackListener'的成员.

我创建了以下界面 -

public interface IWeatherCallbackListener<T> {
 void getWeatherData(T weatherModel, Boolean success, String errorMsg);
}
Run Code Online (Sandbox Code Playgroud)

并按以下方式调用它,

public class WeatherConditions {

private static IWeatherApi mWeatherApi;

/**
 * @param city
 * @param appId
 * @param listener
 */
public static void getOpenWeatherData(String city, String appId, IWeatherCallbackListener listener) {

    mWeatherApi = ApiService.getRetrofitInstance(BASE_URL_OPEN_WEATHER).create(IWeatherApi.class);
    Call<OpenWeatherModel> resForgotPasswordCall = mWeatherApi.getOpenWeatherData(appId, city);
    resForgotPasswordCall.enqueue(new Callback<OpenWeatherModel>() {
        @Override
        public void onResponse(Call<OpenWeatherModel> call, Response<OpenWeatherModel> response) {
            if (response.body() != null) {
                if (listener != null)
                    listener.getWeatherData(response.body(), true, "");
            }
        } …
Run Code Online (Sandbox Code Playgroud)

java generics android interface generic-interface

8
推荐指数
1
解决办法
1万
查看次数

位置更新使用Google Play服务和FusedLocationProviderClient

我想使用最新的融合位置提供商客户端在"后台服务"上获取位置更新.我不想使用所有正在使用的位置监听器和Google API客户端.我还需要使用谷歌播放服务提供的位置设置Api来检查位置设置是否禁用或启用"后台服务".请帮助.

android android-location google-play-services fusedlocationproviderapi google-location-services

7
推荐指数
1
解决办法
3988
查看次数

在kotlin中使用Gson在数据类中序列化密封类

Value我在数据类下为 json 字段创建了一个密封类CustomAttribute。该字段可以返回StringArray of Strings

我们如何从 json 反序列化这个密封类?

data class CustomAttribute (
     val attributeCode: String,
     val value: Value 
)

sealed class Value {
      class StringArrayValue(val value: List<String>) : Value()
      class StringValue(val value: String)            : Value()
}
Run Code Online (Sandbox Code Playgroud)

json gson kotlin json-deserialization sealed-class

6
推荐指数
1
解决办法
7935
查看次数

Pending Intent不会触发Geofencing中的意图服务

当用户进入已定义的地理围栏区域时,我正在使用意图服务来创建通知.问题是,当我第一次运行应用程序时,它工作正常,我在意向服务上获得待定意图,但几天后( 2-3),我没有获得意向服务所需的意图.

我不知道为什么它会在几天后停止工作.如果我启动应用程序,它将再次正常启动,但在几天后再次停止.

这是我的活动代码 -

public class MainActivity extends AppCompatActivity implements View.OnClickListener, GoogleApiClient.OnConnectionFailedListener, GoogleApiClient.ConnectionCallbacks, ResultCallback, OnRequestPermissionsResultCallback {

GoogleApiClient mGoogleApiClient;
Location mGeoLocation;
Geofence mGeofence;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);

    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .addApi(LocationServices.API)
            .build();


    if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {

        ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION,Manifest.permission.ACCESS_COARSE_LOCATION}, 100);

    }
}


@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
    if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) …
Run Code Online (Sandbox Code Playgroud)

geofencing android-geofence

5
推荐指数
1
解决办法
3702
查看次数

谷歌照片应用程序时间轴功能使用他们创建时的图像年份

我想在回收站视图中实现谷歌照片应用程序时间轴功能,我们可以在创建它们时滚动多年的图像,如下图所示.

谷歌照片年度时间线功能

任何人都可以帮助这个或实现这样的事情.

android timeline scroll photos android-recyclerview

5
推荐指数
1
解决办法
314
查看次数

如何在android可绘制对象中一个接一个地绘制多个形状,类似于垂直方向的Liner布局

我想使用 android 可绘制对象依次绘制以下形状 - 直线和圆形。请参阅随附的屏幕截图。

在此输入图像描述

geometry android shapes drawable layer-list

4
推荐指数
1
解决办法
2730
查看次数

选择项目时 onNavigationItemSelected 不调用

我正在使用以下代码在导航抽屉中添加页脚视图 -

<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:openDrawer="start">

    <include
        layout="@layout/app_bar_main"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <com.google.android.material.navigation.NavigationView
        android:id="@+id/nv_top"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="top|start">

        <androidx.core.widget.NestedScrollView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="vertical">
                <include layout="@layout/nav_header_main"/>

                <com.google.android.material.navigation.NavigationView
                    android:id="@+id/drawer_menu_body"
                    app:elevation="0dp"
                    android:layout_height="0dp"
                    android:layout_width="wrap_content"
                    android:layout_weight="1"
                    app:menu="@menu/activity_main_drawer">

                </com.google.android.material.navigation.NavigationView>

                <include layout="@layout/navigation_drawer_bottom_view"/>
            </LinearLayout>

        </androidx.core.widget.NestedScrollView>
    </com.google.android.material.navigation.NavigationView>


</androidx.drawerlayout.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)

但是现在 onNavigationItemSelected() 没有调用导航抽屉也保持打开状态,直到我们手动滑动它。我正在使用导航组件和导航图。

带有页脚视图的侧边菜单

这是我的活动代码 -

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)
    val toolbar: Toolbar = findViewById(R.id.toolbar)
    setSupportActionBar(toolbar)

    val navController = findNavController(R.id.nav_host_fragment)
    drawer_menu_body.setNavigationItemSelectedListener(this)
    nv_top.setNavigationItemSelectedListener(this)

    appBarConfiguration = AppBarConfiguration(
        setOf(
            R.id.nav_home,
            R.id.nav_gallery,
            R.id.nav_slideshow,
            R.id.nav_tools,
            R.id.nav_share, …
Run Code Online (Sandbox Code Playgroud)

navigation android menu navigation-drawer

-2
推荐指数
1
解决办法
1333
查看次数