Send Array to Different Application - java

I would like to send an array in different application.
So In the first application I have MainActivity. The Activity will start an intent. When I'm trying to make an intent, I found a problem. The problem is ShowArrayActivity "cannot be resolved to a type". Actually ShowArrayActivity class is in another apppication. I have tried to add project in build path, but I have an error message said that a cycle was detected in the build path of project 'sendIntent'..
package com.example.sendintent;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;
import com.example.sendintent.DisplayMessageActivity;
public class MainActivity extends Activity {
public static final String ARRAYS_COUNT = "com.example.sendintent.MainActivity.ARRAYS_COUNT";
public static final String ARRAY_INDEX = "com.example.sendintent.MainActivity.ARRAY_INDEX";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public void sendMessage(View view)
{
final String data[][] = new String[][]
{{"Car","75","loaded"},
{"Motor","25","loaded"},
{"Truck","30","loaded"},
{"Bike","40","loaded"},
{"Boat","10","loaded"}};
Bundle bundle = new Bundle();
int count = data.length;
bundle.putInt(ARRAYS_COUNT, count);
for (int i = 0; i < count; i++)
bundle.putStringArray(ARRAY_INDEX + i, data[i]);
Intent intent = new Intent(this, ShowArrayActivity.class); ---->ERROR
intent.putExtras(bundle);
startActivity(intent);
}
}
In Manifest I have declare
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.sendintent"
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="com.example.sendintent.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="com.example.sendintent.DisplayMessageActivity"
android:parentActivityName="com.example.sendintent.MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.sendintent.MainActivity" />
</activity>
<service android:name="com.example.sendintent.MainActivity" />
<receiver android:name="com.example.receiver.MainActivityReceiver">
<intent-filter>
<action android:name="com.example.sendintent.MainActivity.ARRAYS_COUNT"/>
<action android:name="com.example.sendintent.MainActivity.ARRAYS_INDEX"/>
</intent-filter>
</receiver>
</application>
</manifest>
In another application, I have declare the receiver for the intent. It called MainActivityReceiver
package com.example.receiver;
import java.util.ArrayList;
import com.example.sendintent.MainActivity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
public class MainActivityReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
intent.setClass(context, MainActivity.class);
context.startService(intent);
}
}
I have another class called ShowArrayAcivity:
package com.example.receiver;
import java.util.ArrayList;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class ShowArrayActivity extends Activity {
public String[][] data;
public static final String ARRAYS_COUNT = "com.example.sendintent.MainActivity.ARRAYS_COUNT";
public static final String ARRAY_INDEX = "com.example.sendintent.MainActivity.ARRAY_INDEX";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Bundle bundle = getIntent().getExtras();
if (bundle != null) {
int count = bundle.getInt(ShowArrayActivity.ARRAYS_COUNT, 0);
ArrayList<String[]> arrays = new ArrayList<String[]>(count);
for (int i = 0; i < count; i++)
arrays.add(bundle.getStringArray(ShowArrayActivity.ARRAY_INDEX + i));
data = arrays.toArray(new String[][]{});
}
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
In Manifest for receiver application
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.receiver"
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="com.example.receiver.ShowArrayActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name="com.example.sendintent.MainActivity" />
<receiver android:name="com.example.receiver.MainActivityReceiver">
<intent-filter>
<action android:name="com.example.sendintent.MainActivity.ARRAYS_COUNT"/>
<action android:name="com.example.sendintent.MainActivity.ARRAYS_INDEX"/>
</intent-filter>
</receiver>
</application>
</manifest>
In receiver application, It won't show the array from sendIntent application in Interface. I just want to know the way to use broadcast and intent. So if I run in debug mode,in ShowArrayActivity, the variable data will containt the result of the intent.
So my questions is,why I can't use another class when I try to send the intent? Did I forgot something to implement for madethe communication between 2 application?

Intent intent = new Intent(this, ShowArrayActivity.class);
this way you tell activity to find ShowArrayActivity within this Application and launch it. It fails as Application can't find it in it's manifest.
Create Intent with action.
Intent intent = new Intent (NAME_OF_THE_FILTER);
then replace string it second manifest
assuming
public static final String NAME_OF_THE_FILTER = "com.myapp.myfilter"
<intent-filter>
<action android:name="com.myapp.myfilter"/>
</intent-filter>

Related

Android app suddenly stops

I am learning the basics of android programming. Now I have made a Life Cycle test. The list activity works fine, but when I attempt to open the Life Cycle test, the app stops and closes. I have got the same problem on several devices. These are my codes:
(Manifest)
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.badlogic.androidgames"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".AndroidBasicsStarter"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
</manifest>
(AndroidBasicsStarter.java)
package com.badlogic.androidgames;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class AndroidBasicsStarter extends ListActivity {
String tests[] = { "LifeCycleTest", "SingleTouchTest", "MultiTouchTest", "KeyTest",
"AccelerometerTest", "AssetsTest", "ExternalStorageTest", "SoundPoolTest",
"MediaPlayerTest", "FullScreenTest", "RenderViewTest", "ShapeTest", "BitmapTest",
"FontTest", "SurfaceViewTest"
};
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, tests));
}
#Override
protected void onListItemClick(ListView list, View view, int position, long id) {
super.onListItemClick(list, view, position, id);
String testName = tests[position];
try {
Class clazz = Class
.forName("com.badlogic.androidgames." + testName);
Intent intent = new Intent(this, clazz);
startActivity(intent);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
}
(LifeCycleTest.java)
package com.badlogic.androidgames;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
public class LifeCycleTest extends Activity {
StringBuilder builder = new StringBuilder();
TextView textView;
private void log(String text) {
Log.d("LifeCycleTest", text);
builder.append(text);
builder.append('\n');
textView.setText(builder.toString());
}
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
textView = new TextView(this);
textView.setText(builder.toString());
setContentView(textView);
log("created");
}
#Override
protected void onResume() {
super.onResume();
log("resumed");
}
#Override
protected void onPause() {
super.onPause();
log("paused");
if (isFinishing()) {
log("finishing");
}
}
}
I use Eclipse on Windows 7. Thank you in advance!
Add your LifeCycleTest activity in AndroidManifest.xml
<activity
android:name=".LifeCycleTest"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
Include both your activities inside your Manifest file. It should look something like this.
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".AndroidBasicsStarter"
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=".LifeCycleTest"
android:label="#string/app_name" >
</activity>
</application>

Program runs with no errors but button wont open

I have been following the mybringback tutorials on youtube and I tried implementing what I learned. Trying to get a button on my main page to open another page. Finally got the program to run without errors but now when I press the button nothing opens.
Main .xml file where my button is
<Button
android:id="#+id/btnChpt3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:text="Appearance and Grooming Policies"
android:textSize="18sp"
android:textStyle="bold|italic"
android:gravity="center"
/>
Name of .xml file im trying to get to is chapter3.xml
Menu.java
package com.th3ramr0d.learnar670_1;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class Menu extends Activity{
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button chapterThree = (Button) findViewById(R.id.btnChpt3);
chapterThree.setOnClickListener(new View.OnClickListener() {
// #Override
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity(new Intent("com.th3ramr0d.learnar670_1.CHAPTER3"));
}
});
}
#Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
}
}
And my manifest.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.th3ramr0d.learnar670_1"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="21" />
<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=".Menu"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.th3ramr0d.learnar670_1.MENU" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".Chapter3"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.th3ramr0d.learnar670_1.CHAPTER3" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
So button ided as btnChpt3 wont open up my .xml file named chapter3.xml. Thanks for the help.
Here is my Chapter3.java
package com.th3ramr0d.learnar670_1;
import android.app.Activity;
import android.os.Bundle;
public class Chapter3 extends Activity{
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.chapter3);
}
}
Here is my MainActivity.java
package com.th3ramr0d.learnar670_1;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
Copy this and paste in your AndroidManifest and try,
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.th3ramr0d.learnar670_1"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="21" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".Menu"
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=".Chapter3"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.th3ramr0d.learnar670_1.CHAPTER3" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
To help you understand the problem,
<category android:name="android.intent.category.LAUNCHER" />
The code above in the AndroidManifest defines the activity to be launced when the App Icon is pressed. As per your earlier manifest, it launches the activity MainActivity which also sets it setContentView(R.layout.activity_main); by default as the IDE creates a Hello World program.
So when you launch you app, its MainActivity (that looks the same layout you have designed) which is loading and not Menu activity which you want to load. Hence making few changes in the manifest where we declare the Menu activity as the launcher now launches Menu activity which has the piece of code to process your button click.
I hope this helped!
Actually you can try a more convenient way of starting activities inside your application:
startActivity(new Intent(Menu.this, Chapter3.class))
Also you can read more how it works here:
http://developer.android.com/training/basics/firstapp/starting-activity.html
Good day.
Try replacing the line :
startActivity(new Intent("com.th3ramr0d.learnar670_1.CHAPTER3"));
with the code below :
Intent intent = new Intent(Menu.this, Chapter3.class);
startActivity(intent);
Try reverting your code to the original code, copy your layout activity_main.xml and rename it menu.xml.
now in the layout menu.xml change this line:
android:text="Appearance and Grooming Policies"
to:
android:text="Go to menu"
and the line:
android:id="#+id/btnChpt3"
with:
android:id="#+id/btnMenu"
and replace the line:
setContentView(R.layout.activity_main);
in Menu.java with:
setContentView(R.layout.menu.xml);
finally in MainActivity.java add the following to your oncreate method:
Button btnGoToMenu = (Button) findViewById(R.id.btnMenu);
btnGoToMenu.setOnClickListener(new View.OnClickListener() {
// #Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this, Menu.class);
startActivity(intent);
}
});
and re-run the application.

Why do I get a syntax error on line 1?

I'm trying to get this to open an url when the icon is selected/clicked, but I get Syntax error on tokens, delete these tokens on the line String url =
String url = "http://www.google.co.uk/";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
Manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.openurl"
android:versionCode="1"
android:versionName="1.0" >
<application>
<activity android:name="OpenURL" android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I've now got a bit further on this one but when I load the apk file the icon opens the browser with 2 windows - blank and the url. I;m also unable to use the back button to close the browser - it keeps opening the url. How can I correct these issues?
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="14" />
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name">
<activity
android:name="com.example.myapp.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>
</application>
</manifest>
package com.example.myapp;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String url = "http://www.google.co.uk";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}
}
Many thanks again!
This
String url = "http://www.google.co.uk/";
can never be the first line of a java file.
You file need a structure like:
package a.b.c; // optional
import java.util.List; // optional
public class ClassName { // mandatory
// your code
} // mandatory
If this fixes your error, you should consider reading a Java tutorial.
First of all add the permission for internet in your manifest:
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
then your main should be like this:
public class Main extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.yourmainlayout);
Button button = (Button) findViewById(R.id.yourbuttonid);
button.setOnClickListener(new OnClickListener(){
#Override
public void onClick(View v) {
String url = "http://www.google.co.uk/";
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(i);
}});
}
}

Receiving Android SMS

I have been trying so many different things to get this demo running but i couldn't manage to make it run properly..
This is my Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.messagekeeper"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="9" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.messagekeeper.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=".SmsReciever">
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
</application>
</manifest>
This is my MainActivity class (Done nothing with it):
package com.example.messagekeeper;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
And This is the SmsReciever class:
package com.example.messagekeeper;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.telephony.SmsMessage;
import android.util.Log;
class SmsReciever extends BroadcastReceiver{
#Override
public void onReceive(Context context, Intent intent){
Object[] pdus=(Object[])intent.getExtras().get("pdus");
SmsMessage shortMessage=SmsMessage.createFromPdu((byte[]) pdus[0]);
Log.d("SMSReceiver","SMS message sender: "+
shortMessage.getOriginatingAddress());
Log.d("SMSReceiver","SMS message text: "+
shortMessage.getDisplayMessageBody());
}
}
When i get a message, i want it to see it on my app. In this situation, i mean when i use this codes and run my app on emulator, and send a message from one emulator to another, my app crashes and i get this error: http://puu.sh/1yZub
If you've copied your code exactly as it stands, you might be just missing the public keyword at the beginning.
Change class SmsReciever extends BroadcastReceiver{
to public class SmsReciever extends BroadcastReceiver{

Start new Activity from menu

I wrote simple android app with bugs. When open second activity from menu- android stopped apps.
Code:
Manifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="10" />
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".Activit"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<activity android:name=".Activit2"/>
</manifest>
First Activity:
package com.example;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ContextMenu.ContextMenuInfo;
import android.widget.AdapterView.AdapterContextMenuInfo;
public class Activit extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.me, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item){
switch(item.getItemId()){
case R.id.ok: Activ();
};
return super.onOptionsItemSelected(item);
}
private void Activ(){
Intent inten=new Intent();
inten.setClass(Activit.this, Activit2.class);
startActivity(inten);
}
}
Second Activity with temporary layout(it the same in the first):
package com.example;
import android.app.Activity;
import android.os.Bundle;
public class Activit2 extends Activity{
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
your tag <Activity /> should be in ( not out ) of the tag <application> :
try this :
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".Activit"
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=".Activit2"/> // you should declare your activity Here
</application>
The tag <activity android:name=".Activit2"/> should be inside the <application> tag in your Manifest.xml
Your second activity definition is outside the application definition in your AndroidManifest.xml.

Categories

Resources