I have a problem and I cant figure it out. (I am new in android studio) Maybe someone can help me. I have search on the internet but I can't find a solution.
I using Android Studio 1.4
I want to open aan specific app from my own app. So if I lauch my app I see a few buttons. When I press one of the buttons, an specific app will be open.
the problem is that when I press the button. I receive the message: app is stopped.
What I have done: Created a new project and place an button on the main activity.
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button1"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
The in the MainActivity.java I add the following lines:
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button button = (Button) findViewById(R.id.button1);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent i = new Intent();
i.setClassName("com.android.calculator2",
"com.android.calculator2.Calculator");
startActivity(i);
}
});
Can please someone help me to solve this problem?
Kind regards