小编Pan*_*eet的帖子

某些 Android 手机未在“设置”中打开“关于设备”页面?

运行以下代码时,某些 Android 手机不执行任何操作。它应该在“设置”中打开“关于设备”页面。

例如,我知道它对运行 Android 10的华为 Y9 Prime 2019 没有影响。

startActivity(new Intent(Settings.ACTION_DEVICE_INFO_SETTINGS));
Run Code Online (Sandbox Code Playgroud)

发生此问题时,预防此问题的最佳方法是什么?(在我的应用程序中,我打开此页面以要求用户在那里执行特定操作)

java android

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

按下对话框按钮时打开另一个活动?

当按下此评级对话框中的任何按钮时,我想成功运行下面的代码(属于此库)。我该怎么做?

  public void goToPickerActivity() {
    Intent intent = new com.sucho.placepicker.PlacePicker.IntentBuilder()
            .onlyCoordinates(true) //Get only Coordinates from Place Picker
            .showLatLong(true)
            .setLatLong(40.71274, -74.005974)  // Initial Latitude and Longitude the Map will load into (NYC coordinates)
            .setMapZoom(2.5f)  // Map Zoom Level. Default: 14.0
            .build(this);

    startActivityForResult(intent, Constants.PLACE_PICKER_REQUEST);
  }
Run Code Online (Sandbox Code Playgroud)

编辑:我想执行goToPickerActivity() 第一 ,然后执行库的预期点击代码。例如,当Rate App单击按钮时:

第 1 步是:执行goToPickerActivity().

完成后,第 2 步是:运行通常Rate App单击的代码。

java android dialog

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

以编程方式正确打开“设置”中的“关于设备”页面?

startActivity(new Intent(android.provider.Settings.ACTION_DEVICE_INFO_SETTINGS)); 在三星设备中打开此页面:

在此处输入图片说明

但是,我希望它像其他 Android 设备一样打开此页面,我该怎么做?

在此处输入图片说明

java android android-intent

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

以编程方式更改 SIM 卡国家?

如何在没有 root 访问权限的情况下以编程方式更改 Android 手机 SIM 卡的国家/地区和网络?我正在使用此代码来检索信息:

TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);

System.out.println(tm.getSimCountryIso()); // prints 'us', but I want it to be 'fr'
System.out.println(tm.getNetworkCountryIso()); // prints 'us, but I want it to be 'fr'
Run Code Online (Sandbox Code Playgroud)

由于我的 SIM 卡来自美国,因此两个输出均为us. 例如,如何以编程方式使输出为fr(法国)?

基本上,例如,我想欺骗我的智能手机,使其认为其 SIM 卡的国家和网络是法国

像这样的东西将是完美的,但它不存在:

tm.setSimCountryIso('fr')

tm.setNetworkCountryIso('fr')

java android

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

警报对话框不适应暗模式和非暗模式

为什么我的警报对话框不适应我手机的暗模式?在我的手机中激活暗模式时,几乎看不到两个按钮的文本,而标题和消息颜色则相反。为什么按钮颜色也不反转?该图标在非深色模式下也不能很好地显示。如何解决所有这些问题?

在此处输入图片说明 在此处输入图片说明

  val builder = AlertDialog.Builder(this)
  builder.setTitle(getString(R.string.title))
  builder.setMessage(getString(R.string.message))

  builder.setPositiveButton(getString(R.string.positive)) { dialog, which ->
        
    Toast.makeText(applicationContext, getString(R.string.pos_toast), Toast.LENGTH_LONG).show()
  }

  builder.setNegativeButton(getString(R.string.negative)) { dialog, which ->

    Toast.makeText(applicationContext, getString(R.string.negative_toast), Toast.LENGTH_LONG).show()
  }

  builder.setIcon(android.R.drawable.ic_dialog_alert)
  builder.show()
Run Code Online (Sandbox Code Playgroud)

我的 stiles.xml:

<resources>

  <!-- Base application theme. -->
  <style name="MyTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
  </style>

  <style name="generalnotitle" parent="MyTheme">
    <item name="android:windowNoTitle">true</item>
  </style>

</resources>
Run Code Online (Sandbox Code Playgroud)

android android-theme android-alertdialog kotlin material-components-android

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

如何在 Android Studio 中禁用外部库活动中的后退按钮?

我正在使用这个库:https : //github.com/suchoX/PlacePicker

如何禁用此地点选择器活动的物理后退按钮?

在此处输入图片说明

这是打开此活动的代码:

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

import com.sucho.placepicker.AddressData;
import com.sucho.placepicker.Constants;
import com.sucho.placepicker.PlacePicker;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        Intent intent = new PlacePicker.IntentBuilder()
                .setLatLong(40.748672, -73.985628)  // Initial Latitude and Longitude the Map will load into
                .showLatLong(true)  // Show Coordinates in the Activity
                .setMapZoom(12.0f)  // Map Zoom Level. Default: 14.0
                .onlyCoordinates(true) //Get only Coordinates from Place Picker
                .build(this);

        startActivityForResult(intent, Constants.PLACE_PICKER_REQUEST);
    }

    @Override
    protected …
Run Code Online (Sandbox Code Playgroud)

java android android-studio

0
推荐指数
2
解决办法
377
查看次数