有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何从json获取数据url?

我有打开这个代码链接的按钮

public class Settings_d extends AppCompatActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.Settings_d );


        Button b = (Button) findViewById(R.id.new8);
        b.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String url = "https://www.google.com";
                Intent i = new Intent(Intent.ACTION_VIEW);
                i.setData(Uri.parse(url));
                startActivity(i);
            }
        });
    }
}

我想在没有更新应用的情况下更新url。。 如何从JSON获取数据url

谢谢


共 (2) 个答案

  1. # 1 楼答案

    你不需要JSON

    JSON, or JavaScript Object Notation, is a minimal, readable format for structuring data. It is used primarily to transmit data between a server and web application, as an alternative to XML. Squarespace uses JSON to store and organize site content created with the CMS. Read more

    您可以这样使用webview:

    <WebView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/webView1" android:layout_width="fill_parent" android:layout_height="fill_parent" />
    

    因此,尝试以下代码来更改按钮中的url:

    webView.getSettings().setJavaScriptEnabled(true);       
    webView.loadUrl("http://www.google.com");
    

    here.中可以看到更多webview插件

  2. # 2 楼答案

    如果您想更改应用程序中的某些数据,请尝试使用onesignal。这是一个免费的推送通知面板,你可以通过它向你的应用程序发送背景数据,你可以在后台服务中做任何事情,而不是显示通知。 Read more