OnClick doesn't appear to be getting called - java

I am trying to open a web browser window onclick of a button.
My click event doesn't appear to be getting called. LogCat shows no errors or any evidence of it being called. I have a feeling this is due to me having 2 methods named 'onClick', but removing the second method causes an error. I can fix this error by making MainActivity abstract, but that crashes the app.
I feel this is a simple fix, but after pouring over documentation and several tutorials I cannot find the answer.
Code is below, followed by my manifest. Thanks in advance.
package com.spotsofmagic.spotsofmagic;
import android.app.Activity;
import android.app.AlertDialog;
import android.bluetooth.BluetoothAdapter;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.net.Uri;
import android.nfc.NdefMessage;
import android.nfc.NdefRecord;
import android.nfc.NfcAdapter;
import android.os.Bundle;
import android.os.Parcelable;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
public class MainActivity extends Activity implements OnClickListener {
private static final String TAG = "Activity...";
private NfcAdapter mAdapter;
private TextView mTextView;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_activity);
// grab our NFC Adapter
mAdapter = NfcAdapter.getDefaultAdapter(this);
// TextView that we'll use to output messages to screen
mTextView = (TextView)findViewById(R.id.text_view);
//displayMessage("Loading payload...");
}
private void displayMessage(String message) {
mTextView.setText(message);
}
public void onClick(View v) {
// TODO Auto-generated method stub
// do something when the button is clicked
displayMessage("Loading broswer");
Uri uriUrl = Uri.parse("http://www.***.com/");
Intent launchBrowser = new Intent(Intent.ACTION_VIEW, uriUrl);
startActivity(launchBrowser);
if(v.getId() == R.id.btnVisitWebsite) {
}
}
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
}
}
And the manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.spotsofmagic.spotsofmagic"
android:versionCode="1"
android:versionName="1.0" android:installLocation="auto">
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="14" />
<uses-permission android:name="android.permission.NFC" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-feature android:name="android.hardware.nfc" android:required="true" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".CardActivity"
android:label="#string/app_name" >
<!-- Handle a collectable card NDEF record -->
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED"/>
<data android:mimeType="application/vnd.spotsofmagic.spotsofmagic"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
</application>
</manifest>

You have an OnClickListener but you didn't attach it to any button. Try
((Button) findViewById(R.id.your_button_id)).setOnClickListener(this);
EDIT: The other problem is, that you implemented DialogInterface.OnClickListener instead of View.OnClickListener in your Activity.
Remove the imports
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
And add
import android.view.View.OnClickListener;
You can also remove
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
}
after this.

Because you didn't associate the click event.
If you are binding it to button (or) something, you need to do bind it for 'this'
Example:
button.setOnClickListener(this);

To avoid confusion, you could also do it using the XML if you are not creating the view programatically. You can do something like this.
<Button android:width="20dp" android:height="20dp" android:onClick="openBrowser" />
and provide the method in your program as
public void openBrowser(View v)
{
/* do your stuff here */
}

Related

Moving a file from one computer into other computer

I am a really really new developer. I am currently work a BLE stuff with my friend, but we always have an issue to move my project into his computer, and his project move to my computer.
He does not like to use GitHub at all, me too actually, so we want to just use flash drive to transfer the project folder.(this is the way I found from stackoverflow.com)
I always have errors, and this transfer folder way never work as we respect.
Most of question from "Cannot resolve symbol 'R' such as:
setContentView(R.layout.activity_main);
I already look up online, and most of people just say "clean project", but it does not work at all.
Some of people said, activity_main.xml has problem, but I cant find the problem.
MainActivity.java
package test.research.sjsu.beaconbroadcast;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothManager;
import android.bluetooth.le.AdvertiseCallback;
import android.bluetooth.le.AdvertiseData;
import android.bluetooth.le.AdvertiseSettings;
import android.bluetooth.le.BluetoothLeAdvertiser;
import android.content.Context;
import android.os.Bundle;
import android.os.ParcelUuid;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import java.util.UUID;
public class MainActivity extends AppCompatActivity {
BluetoothManager mBluetoothManager;
BluetoothAdapter mBluetoothAdapter;
BluetoothLeAdvertiser mBluetoothLeAdvertiser;
AdvertiseData mAdvertiseData;
AdvertiseData.Builder mAdvertiseDataBuilder = new AdvertiseData.Builder();
byte[] Data = new byte[4];
ParcelUuid mServiceDataUUID;
AdvertiseSettings mAdvertiseSettings;
AdvertiseSettings.Builder mAdvertiseSettingBuilder = new AdvertiseSettings.Builder();
Button BroadcastButton;
Button StopBroadcastButton;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mBluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
mBluetoothAdapter = mBluetoothManager.getAdapter();
mBluetoothLeAdvertiser = mBluetoothAdapter.getBluetoothLeAdvertiser();
Data = hexStringToByteArray("abcdefgh");
mServiceDataUUID = ParcelUuid.fromString(UUID.randomUUID().toString());
mAdvertiseDataBuilder.setIncludeDeviceName(true);
mAdvertiseDataBuilder.setIncludeTxPowerLevel(true);
mAdvertiseData = mAdvertiseDataBuilder.build();
mAdvertiseDataBuilder.addServiceData(mServiceDataUUID,Data);
mAdvertiseSettingBuilder.setAdvertiseMode(1);
mAdvertiseSettingBuilder.setTimeout(0);
mAdvertiseSettingBuilder.setTxPowerLevel(2);
mAdvertiseSettingBuilder.setConnectable(true);
mAdvertiseSettings = mAdvertiseSettingBuilder.build();
BroadcastButton = (Button) findViewById(R.id.BroadcastButton);
BroadcastButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
startAdvertise();
}
});
StopBroadcastButton = (Button) findViewById(R.id.StopBraodcastButton);
StopBroadcastButton.setVisibility(View.INVISIBLE);
StopBroadcastButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
stopAdvertise();
}
});
}
Here is my activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="test.research.sjsu.beaconbroadcast">
android:versionCode="1"
android:versionName="1.0"
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-feature android:name="android.hardware.bluetooth_le" android:required="true" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Sometime there are other red lines, but now the R problem just make me crazy.

SMS Broadcast Receiver not working

Alright, I have tried every solution on Stack and nothing works.My current method registers the "SmsListener" receiver from the MainActivity. All I'm trying to do is initialize the onReceive method. There are no errors; It simply isn't picking up a broadcast. What am I doing wrong? Pasting the applicable code here. Anything else that may be needed please just ask.
Update:
Here is a similar unresolved issue
Listen Android incoming SMS when Google Hangout or other app receives it
I am testing under Android 6.0.1. Target Sdk version is 22. Min Sdk is 19. It's worth noting that I just tested my original code on an LG Optimus GPro with Android 4.4.2 and it worked. It still isn't working on my Nexus with Android 6.0.1.
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.biapps.makin_biscuits">
<uses-sdk android:minSdkVersion="4" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.SEND_SMS"/>
<uses-permission android:name="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"/>
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.WRITE_SMS" />
<uses-permission android:name="android.permission.READ_SMS" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action `android:name="android.service.notification.NotificationListenerService" />`
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ContactsList">
<intent-filter>
<category android:name="android.intent.category.ALTERNATIVE" />
</intent-filter>
</activity>
<receiver
android:name=".SmsListener"
android:priority="999"
android:enabled="true"
android:exported="true">
</receiver>
<receiver
android:name=".IncomingCallReceiver"
android:enabled="true"
android:exported="true">
</receiver>
</application>
Main Activity
package com.biapps.makin_biscuits;
import android.service.notification.NotificationListenerService;
import android.app.NotificationManager;
import android.content.Context;
import android.content.IntentFilter;
import android.media.AudioManager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.content.Intent;
import android.view.View;
import android.widget.ImageButton;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
//set object labels and states here
private ImageButton icon;
private AudioManager am;
private ImageButton people;
private ImageButton ring;
private NotificationManager nm;
private NotificationListenerService nls;
IncomingCallReceiver broadCastReceiver = new IncomingCallReceiver();
SmsListener smsReceiver = new SmsListener();
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
icon = (ImageButton) findViewById(R.id.icon);
icon.setOnClickListener(imgButtonHandler);
people = (ImageButton) findViewById(R.id.people);
//people.setOnClickListener(peopleButtonHandler);
ring = (ImageButton) findViewById(R.id.ring);
}
int buttonstate = 0;
public View.OnClickListener imgButtonHandler = new View.OnClickListener() {
public void onClick(View v) {
if (buttonstate == 0) {
icon.setImageResource(R.drawable.buttonup);
buttonstate = 1;
am.setRingerMode(0);
registerReceiver(broadCastReceiver, new IntentFilter(
"android.intent.action.PHONE_STATE"));
registerReceiver(smsReceiver, new IntentFilter(
"android.intent.action.DATA_SMS_RECEIVED"));
registerReceiver(smsReceiver, new IntentFilter(
"android.provider.Telephony.SMS_RECEIVED"));
registerReceiver(smsReceiver, new IntentFilter(
"android.provider.Telephony.DATA_SMS_RECEIVED"));
Toast.makeText(getApplicationContext(),"Diving!", `Toast.LENGTH_SHORT)`
.show();
} else {
icon.setImageResource(R.drawable.button);
buttonstate = 0;
am.setRingerMode(2);
unregisterReceiver(broadCastReceiver);
unregisterReceiver(smsReceiver);
Toast.makeText(getApplicationContext(),"Surfacing!", Toast.LENGTH_SHORT)
.show();
}
}
};}
SmsListener
package com.biapps.makin_biscuits;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.provider.Telephony;
import android.telephony.SmsMessage;
import android.util.Log;
import android.widget.Toast;
import android.telephony.TelephonyManager;
public class SmsListener extends BroadcastReceiver {
private static final String TAG = "SmsListener";
public static final String SMS_BUNDLE = "pdus";
#Override
public void onReceive(Context context, Intent intent) {
Toast.makeText(context, "ON SMS RECEIVE BROADCAST", Toast.LENGTH_LONG).show();
Log.i(TAG, "SmsListener - onReceiveCalled");
}}
Try following way with highest reading priority value,
<receiver android:name=".SmsListener"
android:enabled="true"
android:exported="true"
android:permission="android.permission.READ_SMS">
<intent-filter android:priority="2147483647">
<action android:name="android.provider.Telephony.SMS_RECEIVED"/>
</intent-filter>
</receiver>
This will surely solve out your problem.
Update from below comment,
Since you are checking on Android version 6.0.1 just follow these steps,
Go to Settings,
Go to Apps
Select your Application
Choose Permissions Option
Enable SMS permission
After spending more than an hour I found that RECEIVE_SMS permission is required.
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.RECEIVE_SMS},
MY_PERMISSIONS_REQUEST_SMS_RECEIVE);
Prioirty is not required to be set. This should work.
Found a solution.
First make another app your default SMS app.
Then: Google Hangout --> Settings (Disable merged conversations) --> SMS (Disable SMS)
You are registering broadcast your in your Activity, so it won't work if your app is in background. you can remove this from your Activity and you can register it in Manifest.
ex:
<receiver android:name=".SmsListener">
<intent-filter android:priority="999">
<action android:name="android.provider.Telephony.SMS_RECEIVED"/>
</intent-filter>
</receiver>
Along with this add permission to recieve sms.
Try this, and it will work

Access the volume button through my android app

I am developing an android app which should be able to identify when someone press the hardware volume up button of the phone , and give a notification saying "volume up button has pressed".
This is my BroadcastReceiver class.
package com.example.volumebut;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.view.KeyEvent;
import android.widget.Toast;
public class HardwareButtonReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
KeyEvent e = (KeyEvent) intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);
if(e.getKeyCode() == KeyEvent.KEYCODE_VOLUME_UP) {
Toast.makeText(context, "volume up button pressed." ,Toast.LENGTH_LONG).show();
}
}
}
This is my manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.volumebut"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.volumebut.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name=".HardwareButtonReceiver">
<intent-filter>
<action android:name="android.intent.action.MEDIA_BUTTON" />
</intent-filter>
</receiver>
</application>
</manifest>
Since I am new to android development I have no idea how to implement MainActivity.java file.
This is the MainActivity.java file I have wrote so far. But it gives an error saying "The method registerMediaButtonEventReceiver(HardwareButtonReceiver) is undefined for the type MainActivity"
package com.example.volumebut;
import android.media.AudioManager;
import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.view.Menu;
public class MainActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
HardwareButtonReceiver receiver = new HardwareButtonReceiver();
registerMediaButtonEventReceiver(receiver);
}
}
If you guys can help me to solve my problem I appreciate It much.
http://developer.android.com/reference/android/view/KeyEvent.html
go through above link you will get different key events
#Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
//
}
else if(keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)
{
}
return super.onKeyDown(keyCode, event);
}
You must add method registerMediaButtonEventReceiver to your activity class.
public class MainActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.xml_of_your_activity);
HardwareButtonReceiver receiver = new HardwareButtonReceiver();
registerMediaButtonEventReceiver(receiver);
}
private void registerMediaButtonEventReceiver(HardwareButtonReceiver receiver) {
}
}
And then implement it of course.

Background service doesn't work

I am trying to create an Android app in Android Studio.
The app is mainly a background service to send some information to the server around every 15 seconds or so.
I have created an empty activity, boot receiver and a service class, but it doesn't work.
Could somebody help me, and explain why it doesn't work.
The relevant files:
MainActivity.java
package nl.robinvandervliet.robinsapp.app;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
public class MainActivity extends ActionBarActivity
{
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
finish();
}
}
BootReceiver.java
package nl.robinvandervliet.robinsapp.app;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
public class BootReceiver extends BroadcastReceiver
{
#Override
public void onReceive(Context context, Intent intent)
{
context.startService(new Intent(context, RobinsService.class));
}
}
RobinsService.java
package nl.robinvandervliet.robinsapp.app;
import android.app.Notification;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.widget.Toast;
public class RobinsService extends Service
{
private Runnable runnable = new Runnable()
{
#Override
public void run()
{
//Opening connection to the server.
while (true)
{
//Sending some data to the server.
//Sleeping for around 15 seconds.
}
//Dead code, should never reach this place.
}
};
public IBinder onBind(Intent intent)
{
return null;
}
#Override
public void onCreate()
{
new Thread(runnable).start();
Notification notification = new Notification.Builder(getApplicationContext()).setContentTitle("MyService is running!").setContentTitle("(more information later)").build();
startForeground(1, notification);
Toast.makeText(getApplicationContext(), "Service created!", Toast.LENGTH_LONG).show();
}
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="nl.robinvandervliet.robinsapp.app" >
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="nl.robinvandervliet.robinsapp.app.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name="nl.robinvandervliet.robinsapp.app.BootReceiver" android:enabled="true" android:exported="false">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<service android:name="nl.robinvandervliet.robinsapp.app.RobinsService" android:exported="false" />
</application>
<uses-permission android:name="android.permission.BATTERY_STATS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
</manifest>
Thanks, Robin.
Since you haven't implemented some parts yet I assume you just want it to run when you boot your device. Maybe take a look here. Adding an extra action in the manifest might solve your problem.

"No Activity found" error

This is my main page code:
package com.example.splasher;
import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.view.View;
import android.view.View.OnFocusChangeListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
public class MainActivity extends Activity {
public static String text;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
// hide statusbar of Android
// could also be done later
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
Button button = (Button) findViewById(R.id.button1);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Perform action on click
EditText field= (EditText) findViewById (R.id.editText1);
field.setOnFocusChangeListener(new OnFocusChangeListener(){
public void onFocusChange(View v, boolean hasFocus){
if (hasFocus) ((EditText)v).selectAll();
}
});
text=field.getText().toString();
try{
startActivity(new Intent("com.example.splasher.View"));
}
catch(ActivityNotFoundException e){
}
}
});
}
}
This is the code of my called activity:
package com.example.splasher;
import android.os.Bundle;
import android.app.Activity;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;
public class View extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
// hide statusbar of Android
// could also be done later
// getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
// WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.view);
// TextView textview=(TextView) findViewById (R.id.textView1);
// textview.setText(MainActivity.text);
}}
And this is my manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.splasher"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".View"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.example.splasher.View" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I can't work out why I get this error. Any ideas? Names are all the same and with same upper, lower case letters. They are all described in manifest as well.
In your manifest, type the activity action in caps.
< action android:name="COM.EXAMPLE.SPLASHER.VIEW" / >
this is done for all activities except for the main activity
There is MainActivity.this.startActivity(new Intent(MainActivity.this, Views.class)); Views class with 's' !
there is no need of the intent filter which you have applied in the View activity..Just keep one intent filter in your MainActivity
Replace the start activity line code with following:
startActivity(new Intent(MainActivity.this,View.class));
Try to replace your startActivity call by MainActivity.this.startActivity in your MainActivity.
I think there is a scope trouble.

Categories