【问题标题】:Android Studio open intent and data inputAndroid Studio 打开意图和数据输入
【发布时间】:2017-06-13 08:14:27
【问题描述】:

我在 Android Studio 上使用 Intent 打开设置。我想在稍后打开的这些设置的一部分中输入数据。我该怎么做?

对象提交后,图片中的空白(名称、类型等)必须填写。 Picture

Intent intent = new Intent("android.net.vpn.SETTINGS");                              
startActivity(intent);

像这样:

有意投降。 设置页面打开。 我将发送带有意图的变量。 我将把这个变量放在打开的设置页面上。 例如,我会将“Recep”发送到名称字段。 当我们发起意图时,名称字段将填写我们发送的名称。

【问题讨论】:

  • 我尝试了此消息的答案。但我没有成功

标签: android android-intent input


【解决方案1】:

用于有意图地传递数据

Intent intent  = new Intent(android.provider.Settings.ACTION_SETTINGS), 0);
Intent intent  = new Intent(android.provider.Settings.ACTION_SETTINGS), 0);
intent.putExtra("key", value);
startActivity(intent);

【讨论】:

    【解决方案2】:
    Intent i=new Intent(context,example.class);
    i.putExtra("id", "1");
    startActivity(i);
    

    稍后您可以使用 .

    检索
     String id = intent.getStringExtra("id");
    

    【讨论】:

      【解决方案3】:

      你可以用这个来实现上面的!!我在 Kitkatlollipop 设备上对此进行了测试,在这两个设备上都可以正常工作

       Intent intent = new Intent();
      intent.setComponent(new ComponentName("com.android.settings","com.android.settings.Settings$DataUsageSummaryActivity"));
      startActivity(intent);
      

      更新

      public static void showDataRoamingScreen()
       {
      if(Build.VERSION.SDK_INT > 15)
      {
          _showSettingScreen("android.settings.DATA_ROAMING_SETTINGS");
      }
      else
      {
          Intent intent=new Intent(Settings.ACTION_DATA_ROAMING_SETTINGS);
          ComponentName cName = new ComponentName("com.android.phone","com.android.phone.Settings");
          intent.setComponent(cName);
          intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
          Reference.getAppContext().startActivity(intent);
      }
      }
      
      
      
       public static void showDataMobileScreen()
       {
      if(Build.VERSION.SDK_INT > 15)
      {
          Intent intent = new Intent(Settings.ACTION_WIRELESS_SETTINGS);//android.provider.Settings.ACTION_SETTINGS //Intent.ACTION_MAIN
          intent.setClassName("com.android.settings", "com.android.settings.Settings$DataUsageSummaryActivity");
          intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
          Reference.getAppContext().startActivity(intent);
      }
      else
      {
          showDataRoamingScreen();
      }
      }
      
      
      protected static void _showSettingScreen(String intentStr)
      {
      try
      {
          Intent intent = new Intent(intentStr);
          intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
          Reference.getAppContext().startActivity(intent);
      }
      catch (Exception e) {Reference.showToast(e.toString(), true);}
      }
      

      【讨论】:

      • @RecepKara 这是您问题的解决方案吗?
      • 我正在尝试。但我遇到了一个错误。 Reference.getSystem 无法识别分区。
      • @RecepKara 立即尝试
      • 我知道我让你很难受。但不幸的是我失败了。 - _showSettingScreen,。 -Reference.getAppContext() startActivity(意图);我在这些部分遇到了问题
      • @RecepKara 这是我的错误,我忘了提到那个方法。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-08-25
      • 1970-01-01
      • 1970-01-01
      • 2014-10-29
      • 1970-01-01
      • 2019-07-17
      • 1970-01-01
      相关资源
      最近更新 更多