小编Jak*_*ton的帖子

如何修复调用失败的服务器意外响应:Android Studio中未经授权

我在Gitlab上有一个项目,最近几天我一直在处理它!

现在我想pull在家用PC上进行项目,但显示以下错误:

Invocation failed Unexpected Response from Server:  Unauthorized
        java.lang.RuntimeException: Invocation failed Unexpected Response from Server:  Unauthorized
        at org.jetbrains.git4idea.nativessh.GitNativeSshAskPassXmlRpcClient.handleInput(GitNativeSshAskPassXmlRpcClient.java:34)
        at org.jetbrains.git4idea.nativessh.GitNativeSshAskPassApp.main(GitNativeSshAskPassApp.java:30)
        Caused by: java.io.IOException: Unexpected Response from Server:  Unauthorized
        at org.apache.xmlrpc.LiteXmlRpcTransport.sendRequest(LiteXmlRpcTransport.java:231)
        at org.apache.xmlrpc.LiteXmlRpcTransport.sendXmlRpc(LiteXmlRpcTransport.java:90)
        at org.apache.xmlrpc.XmlRpcClientWorker.execute(XmlRpcClientWorker.java:72)
        at org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClient.java:194)
        at org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClient.java:185)
        at org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClient.java:178)
Run Code Online (Sandbox Code Playgroud)

我的Android Studio版本是3.4

java git android gitlab android-studio

37
推荐指数
10
解决办法
4734
查看次数

如何在Android中未经许可阅读接收短信

在某些应用程序中,我看到读取接收短信以获取活动代码!
但是对于阅读此消息不允许任何权限
我的 android 版本是28,我知道在23或更高版本中,我们会从用户那里获得运行时许可
在这个应用程序中如何在没有任何许可的情况下获取已读消息?

android android-permissions runtime-permissions

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

如何在 Android kotlin 上的片段中初始化上下文

在我的应用程序中,我想在显示时显示消息fragment
我用viewPagerBottomNavBar用于表演4fragments
我希望在单击BottomNavBar项目时显示fragment,我希望在可见性 fragment 显示消息显示
我写下面的代码:

class HomeRegisteredFragment : Fragment() {

    lateinit var toolbarTile: TextView

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {

        return inflater.inflate(R.layout.fragment_home_registered, container, false)
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        //Initialize
        activity?.let {
            toolbarTile = it.findViewById(R.id.homePage_toolbarTitle)
        }
        //Set title
        toolbarTile.text = resources.getString(R.string.registered)
        context?.let { ContextCompat.getColor(it, R.color.blue_active) }?.let {
            toolbarTile.setTextColor(it)
        }
    }

    override fun setUserVisibleHint(isVisibleToUser: …
Run Code Online (Sandbox Code Playgroud)

android android-context android-fragments kotlin

3
推荐指数
2
解决办法
2万
查看次数

如何在Android Studio中重新格式化XML布局

在我的项目中,我在XML布局的设计选项卡中创建了一些UI 。但是当我转到“文本”选项卡时,代码格式不正确!

我从右键菜单上选择了“ 重新格式化代码”,但是代码仍然没有正确格式化!XML

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
        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:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".MainActivity">


    <EditText
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:inputType="textPersonName"
            android:ems="10"
            android:id="@+id/nameTxt" android:layout_marginEnd="8dp"
            app:layout_constraintEnd_toEndOf="parent" android:layout_marginRight="8dp" android:layout_marginStart="8dp"
            app:layout_constraintStart_toStartOf="parent" android:layout_marginLeft="8dp"
            app:layout_constraintTop_toTopOf="parent" android:layout_marginTop="8dp" android:hint="Name"/>
</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)

如何重新格式化以上代码?

xml android-studio

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

如何修复Android的预期API级别为21+,但在Android中为19

在我的应用程序中,我想从服务器获取数据,为了连接到服务器,我使用了RetrofitOkHttp
但是在运行应用程序时,显示强制关闭错误。
在android api 21+中没有错误,但是在api 21以下显示强制关闭错误。

ApiClient类代码:

class ApiClient constructor(private val deviceUUID: String) {

    private val apiServices: ApiServices

    init {
        //Gson
        val gson = GsonBuilder()
            .setLenient()
            .create()

        //Http log
        val loggingInterceptor = HttpLoggingInterceptor()
        loggingInterceptor.level =
            if (BuildConfig.DEBUG) HttpLoggingInterceptor.Level.BODY else HttpLoggingInterceptor.Level.NONE

        //Http Builder
        val clientBuilder = OkHttpClient.Builder()
        clientBuilder.interceptors().add(loggingInterceptor)
        clientBuilder.addInterceptor { chain ->
            val request = chain.request()
            request.newBuilder().addHeader(AGENT_NAME, AGENT_VALUE).build()
            chain.proceed(request)
        }
        clientBuilder.addInterceptor { chain ->
            val request = chain.request()
            request.newBuilder().addHeader(X_CLIENT_VERSION, APP_VERSION_NAME).build()
            chain.proceed(request)
        }
        clientBuilder.addInterceptor { …
Run Code Online (Sandbox Code Playgroud)

android kotlin retrofit2 okhttp3

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