【问题标题】:Deal with Intent Action (ACTION_NETWORK_OPERATOR_SETTINGS) not being found处理未找到的意图操作 (ACTION_NETWORK_OPERATOR_SETTINGS)
【发布时间】:2010-10-26 08:28:38
【问题描述】:

我正在尝试使用来自This APIandroid.provider.Settings.ACTION_NETWORK_OPERATOR_SETTINGS 但它给出了一个错误。

我认为它的匹配Activity可能不存在。

我该如何使用它。我想做一个可以直接给我可用网络运营商列表的应用程序。

    public void onCreate(Bundle savedInstanceState) { 
        super.onCreate(savedInstanceState); 
        setContentView(R.layout.main); 
        closeButton = (Button)findViewById(R.id.widget29); 
        txt=(TextView)findViewById(R.id.widget28); 
        closeButton.setOnClickListener(new OnClickListener() { 
            //@Override public void onClick(View v) {

【问题讨论】:

  • 也许您可以告诉我们您是如何使用它的(代码 sn-p),以及您遇到了什么错误?
  • public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);设置内容视图(R.layout.main); closeButton = (Button)findViewById(R.id.widget29); txt=(TextView)findViewById(R.id.widget28); closeButton.setOnClickListener(new OnClickListener() { //@Override public void onClick(View v) {
  • @Meet 你剩下的代码在哪里?

标签: android networking settings


【解决方案1】:

您只需尝试将它们发送到运营商列表并处理不可能的情况:

 try {
        Intent intent = new Intent(Settings.ACTION_NETWORK_OPERATOR_SETTINGS);
        startActivity(intent);
    } catch (ActivityNotFoundException e) {
        Log.e("YourApp", "Activity not found, android settings not launched");
    }

    Intent intent = new Intent(Settings.ACTION_NETWORK_OPERATOR_SETTINGS);
    boolean available = intent.resolveActivity(getPackageManager()) != null;
    if(available){
        Log.e("YourApp", "Activity found");
        // act appropriately .. show a button, to then allow the behaviour
    }

【讨论】:

    猜你喜欢
    • 2011-05-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-14
    相关资源
    最近更新 更多