통화 버튼을 추가하려고합니다. 어떤 것이 button14일까요? 다른 모든 단추는 문자열이 링크로 들어있는 WebActivity 파일을 엽니 다.Android 앱에 통화 버튼 추가
Android에서 프로그래밍하기가 정말 쉽습니다. 나는 누군가가 내가 처음부터 앱을 만드는 것을 도와 주었지만 그는 마을을 벗어나서 이것을 끝내야한다. 어떤 도움이 좋을지 !! 여기
package com.myapp.programname;
import com.myapp.programname.R;
import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public void onButton(View view) {
int index = -1;
int id = view.getId();
if (id == R.id.button1) {
index = 0;
}
else if (id == R.id.button2) {
index = 1;
}
else if (id == R.id.button3) {
index = 2;
}
else if (id == R.id.button4) {
index = 3;
}
else if (id == R.id.button5) {
index = 4;
}
else if (id == R.id.button6) {
index = 5;
}
else if (id == R.id.button7) {
index = 6;
}
else if (id == R.id.button8) {
index = 7;
}
else if (id == R.id.button9) {
index = 8;
}
else if (id == R.id.button10) {
index = 9;
}
else if (id == R.id.button11) {
index = 10;
}
else if (id == R.id.button12) {
index = 11;
}
else if (id == R.id.button13) {
index = 12;
}
else if (id == R.id.button14) {
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:123456789"));
startActivity(callIntent);
}
else {
index = 0;
}
Intent intent = new Intent(this, WebActivity.class);
intent.putExtra("link", index);
this.startActivity(intent);
}
}
는 ... 또한
package com.myapp.programname;
import com.myapp.programname.R;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class WebActivity extends Activity {
private class MyWebViewClient extends WebViewClient{
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return false;
}
}
String links[] = {"http://somesite.com",
"http://somesite.com",
"http://somesite.com",
"http://somesite.com",
"http://somesite.com",
"http://somesite.com",
"http://somesite.com",
"http://somesite.com",
"http://somesite.com,
"http://somesite.com",
"http://somesite.com",
"http://somesite.com",
"http://somesite.com"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web);
int index = getIntent().getIntExtra("link", 0);
WebView myWebView = (WebView) findViewById(R.id.webview);
myWebView.getSettings().setJavaScriptEnabled(true);
myWebView.getSettings().setLoadWithOverviewMode(true);
myWebView.getSettings().setUseWideViewPort(true);
myWebView.getSettings().setBuiltInZoomControls(true);
myWebView.getSettings().setPluginState(WebSettings.PluginState.ON);
myWebView.setWebViewClient(new MyWebViewClient());
myWebView.loadUrl(links[index]);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.web, menu);
return true;
}
}
기본 내장 Android "통화 응용 프로그램"또는 사용자가 원하는 모든 것을 사용할 수 있습니다. 이렇게하려면 암시적인 의도를 사용하고 결국 호출 할 번호와 같은 추가 정보를 번들에 넣습니다. –