Jack Trowbridge
Jack Trowbridge

Reputation: 793

Android Intent to other class not working

I have an intent to another class and all it does it just flag up errors. I am using some code that i got from a answer to a question i asked.

My package name is : com.exercise.AndroidAlarmService

The class i am trying to call is : .Hello

Below is how i am calling the class, buts its not working. I am not an expert in android so a explanation in beginners terms would be appreciated.

Log.i("Service", "onStart() is called"); 
Intent callIntent = new Intent(Intent.ACTION_CALL); 
callIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
callIntent.setClassName("com.exercise.AndroidAlarmService", ".Hello");
startActivity(callIntent);

Upvotes: 1

Views: 513

Answers (2)

Ratna Halder
Ratna Halder

Reputation: 2004

Intent intent = new Intent(Intent.ACTION_MAIN); intent.setClassName("com.exercise.AndroidAlarmService", "com.exercise.AndroidAlarmService.Hello"); startActivity(intent);

Upvotes: 1

ρяσѕρєя K
ρяσѕρєя K

Reputation: 132972

use

callIntent.setClassName("com.exercise.AndroidAlarmService",
                "com.exercise.AndroidAlarmService.Hello");

Instead of

callIntent.setClassName("com.exercise.AndroidAlarmService", ".Hello");

Upvotes: 2

Related Questions