I attach a call system event in Android Studio to the call button.

Got 2 errors:

  1. Error: (13, 8) error: class MainActivity.java

  2. 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> 

enter image description here

    1 answer 1

    The MainActivity class must be in the MainActivity.java file. And you have it called Main_acseller .