-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainActivity.java
59 lines (48 loc) · 1.89 KB
/
MainActivity.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package com.example.gecong.gzowdapp;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.TextView;
import com.xys.libzxing.zxing.activity.CaptureActivity;
public class MainActivity extends AppCompatActivity {
private TextView mTvResult;
public TextView webLink;
public final static String EXTRA_MESSAGE = "com.example.gecong.gzowdapp.MESSAGE";
public String weblink;
public Button goToWS;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mTvResult = (TextView) findViewById(R.id.tv_result);
goToWS = (Button) findViewById(R.id.goToWS_bt);
}
public void scan(View view){
startActivityForResult(new Intent(MainActivity.this, CaptureActivity.class),0);
}
public void goToWS(View view){
Intent intent = new Intent(MainActivity.this, WebScreenActivity.class);
String message = webLink.getText().toString();
intent.putExtra(EXTRA_MESSAGE,message);
startActivity(intent);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(resultCode == RESULT_OK){
Bundle bundle = data.getExtras();
String result = bundle.getString("result");
mTvResult.setText(result);
weblink = result;
webLink = (TextView) findViewById(R.id.web_link);
webLink.setText(weblink);
String url = weblink;
WebView view = (WebView) this.findViewById(R.id.webView2);
view.getSettings().setJavaScriptEnabled(true);
view.loadUrl(url);
}
}
}