Приделываю к кнопке call
системное событие звонка в Android Studio.
Получил 2 ошибки:
Error:(13, 8) error: class MainActivity is public, should be declared in a file named MainActivity.java
Error:Execution failed for task ':app:compileDebugJavaWithJavac'. Compilation failed; see the compiler error output for details.
main.java:
package ru.startandroid.develop.p0311simpleintents;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import com.example.tesha.androidseller.R;
public class MainActivity extends Activity implements OnClickListener {
Button btnCall;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
btnCall = (Button) findViewById(R.id.btnCall);
btnCall.setOnClickListener(this);
}
@Override
public void onClick(View v) {
Intent intent;
switch (v.getId()) {
case R.id.btnCall:
intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse("tel:12345"));
startActivity(intent);
break;
}
}
}
main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:weightSum="1">
<Button
android:id="@+id/btnCall"
android:layout_width="match_parent"
android:layout_height="38dp"
android:layout_margin="10dp"
android:text="Call">
</Button>
</LinearLayout>