I've been playing around with this for some time now and am hoping that someone smarter than I will be able to help. My boss has given me an opportunity to learn to develop Android apps and I'm struggling with this one issue. I need to build several apps with multiple activities but can't seem to get past this point. I'm sure it's a problem in my coding, but with so many different ways of doing things, I'm a little confused at this point.
I am building an app that opens a Main activity with two buttons on the page. One is the close button and works fine. I want the next button to open a mapActivity that is set to my campus' location. I am not a student working on a project I just work for a community college. ;-)
What's really wierd is that the EXACT same google.maps code works fine by itself. I just can't get the button to open the Activity without crashing.
Here is my manifest.xml, main.xml, my main.java, Map.java and map.xml. would you please comment and point me in the right direction?
Thanks in advance,
Dave
here are two errors:
11-21 14:50:58.968: W/dalvikvm(437): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
11-21 14:50:58.978: E/AndroidRuntime(437): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=edu.mtsac.mapproject.MAP }
This says the Activity was not found but I can see it in my source files, and in the manifest here:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="edu.mtsac.mapproject"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="3"
android:targetSdkVersion="8" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<uses-library android:name="com.google.android.maps" />
<activity
android:label="#string/app_name"
android:name=".Main" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- map activity -->
<activity
android:label="Map"
android:name=".Map" >
<intent-filter >
<action android:name="edu.mtsac.mapproject.MAP" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
My Main.xml and Map.xml files are simple:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<Button
android:id="#+id/mapBtn"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="Map" />
</RelativeLayout>
Map.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<com.google.android.maps.MapView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/mapView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey="0jevUfyLD_b1Eikgpm_mo7KVDspzhPJdRDDaxEw"
android:clickable="true"
android:enabled="true" />
</LinearLayout>
the Main.java
package edu.mtsac.mapproject;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class Main extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button mapBtn = (Button) findViewById(R.id.mapBtn);
mapBtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
startActivity(new Intent(Main.this, Map.class));
}
});
Button closeBtn = (Button) findViewById(R.id.closeBtn);
closeBtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
finish();
}
});
};// end onCreate()
}
and lastly the Map.java
package edu.mtsac.mapproject;
import android.os.Bundle;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
public class Map extends MapActivity {
MapController mc;
GeoPoint p;
MapView mapview;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map);
mapview = (MapView) findViewById(R.id.mapView);
mapview.displayZoomControls(true);
mapview.setBuiltInZoomControls(true);
mapview.setSatellite(true);
mc = mapview.getController();
String coord[] = { "34.047517", "-117.847050" };
double lat = Double.parseDouble(coord[0]);
double lng = Double.parseDouble(coord[1]);
p = new GeoPoint((int) (lat * 1E6), (int) (lng * 1E6));
mc.animateTo(p);
mc.setZoom(17);
mapview.invalidate();
}
#Override
protected boolean isRouteDisplayed() {
return false;
}
}
I don't see any activity in your manifest registered to handle this action edu.mtsac.mapproject.MAP. I assume that exception is happening when you call:
startActivity(new Intent("edu.mtsac.mapproject.MAP"));
It looks like you're probably trying to start your Map Activity for which you don't need to specify an Action. Just do something like:
startActivity(new Intent(this, Map.class));
You probably want to read this doc on intents to understand what's really going on here and how you should be using these classes.
In the "map" button click implementation you create an Intent whose action is "edu.mtsac.mapproject.MAP". Since your manifest's Intent Filter is looking for action "android.intent.action.MAP" it will not resolve to your activity.
I believe you were confused by explicit vs. implicit intents. Explicit intents use the specific name of the activity you want to use but implicit intents only define an action you want to accomplish.
To get this to work change the map button to start the action in your manifest.
In your Main.java, try to use this code instead:
Button mapBtn = (Button) findViewById(R.id.mapBtn);
mapBtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
startActivity(new Intent(Main.this, Map.class));
}
});
Related
I am new to android development. After setting up an android project, I tried to get text input and passe it to another activity (screen).
When I run the project I don't get an error but when I click the application it shows the first screen then when click the button in the screen it gives the error 'application stopped unexpectedly'.
When I try the code without passing data from first screen to second screen , the application works properly.
This is MainActivity.java file:
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
public class MainActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final EditText et= (EditText) findViewById(R.id.editText1);
Button b = (Button)findViewById(R.id.button1);
b.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
//intent class is used for activating another or component or an activity
Intent intent =new Intent(MainActivity.this, Second.class);
intent.putExtra("textval", et.getText().toString());
startActivity(intent);
}
});}}
Here is the code for Second.java file:
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class Second extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
TextView tv= (TextView) findViewById(R.id.textView1);
tv.setText(getIntent().getExtras().getString("textval"));
}
}
Here is the activitymain.xml code:
<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText android:id="#+id/editText1" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_alignParentLeft="true"
android:layout_alignParentRight="true" android:layout_alignParentTop="true"
android:ems="10"
android:inputType="text"
>
<requestFocus />
</EditText>
<Button android:id="#+id/button1" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_alignParentLeft="true"
android:layout_below="#+id/editText1" android:layout_marginTop="28dp"
android:text="#string/button" />
</RelativeLayout>
Here is the second xml file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"
android:orientation="vertical">
<TextView android:id="#+id/textView1" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="#string/textview" />
</LinearLayout>
Please help me to find the error. Since I don't get an error notification I am not able to proceed.
Thanks in advance...
This is what you missed on your Second.java:
setContentView(R.layout.second);
put it above of your textview declaration.
In your Second java file make changes as follows
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class Second extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.second);
TextView tv= (TextView) findViewById(R.id.textView1);
tv.setText(getIntent().getExtras().getString("textval"));
}
}
Declare Second Activity in android manifest file .
<activity android:name=".Second"/>
Add setContentView(R.layout.second); in second activity.
Add entry for second activity in your Manifest file.
Put first activity as a Launcher and other as a Default.
Here I have two activity MainActivity and Player.
First I Launches MainActivity and then call other activity Player
Note- Activity name should be same as class name, so Keep same in Manifest file as well.
Also you need to specify the layout file for both activity by setContentView in onCreate function.
Here is sample code-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.vt.soc"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Player"
android:label="#string/title_activity_main" >
<intent-filter>
<action android:name="com.vt.soc.PALYER" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
- In your Second Activity you forgot to add the setContentView().
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.second);
TextView tv= (TextView) findViewById(R.id.textView1);
tv.setText(getIntent().getExtras().getString("textval"));
}
- Please also do see that you have added this Second Activity in your Manifest.xml file.
Update:
I have spent more than 2 hours to google, but I can't find the answer. I've add a main.java the handle the activity send from the Login Activity. Now the file tree looks like:
But still got error
E/AndroidRuntime(1282): android.content.ActivityNotFoundException: No
Activity found to handle Intent {
act=com.goodboy.loginIntent.action.main
cat=[android.intent.category.DEFAULT] (has extras) }
I know this question is simple, I am new to android, any help would be appreciated:)
Android allows for Intents that have specific recipients(the Activity or Service) as well as Intents that are broadcast throughout the system to any components that may be listening.
I want to make a PoC(Proof of Concept) that if we do not set setClassName, others can listen your private message.
This PoC is simple, suppose there is Login Activity for App Goodboy, when a user put his username and password in the login activity, and click the login button, the evil activity from App Badboy steal the this message.
However, failed:(
When I click the login button, failed:
And the evil intent got nothing:
The java source code of Login Activity
package com.goodboy.loginIntent;
import com.goodboy.loginIntent.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
public class GoodloginActivity extends Activity {
private EditText et_user;
private EditText et_pwd;
private Button btn_login;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login);
et_user = (EditText) findViewById(R.id.et_user);
et_pwd = (EditText) findViewById(R.id.et_pwd);
btn_login = (Button) findViewById(R.id.btn_login);
btn_login.setOnClickListener(new OnClickListener(){
public void onClick(View v) {
Intent m_intent = new Intent();
m_intent.putExtra("username", et_user.getText().toString());
m_intent.putExtra("password", et_pwd.getText().toString());
m_intent.setAction("com.goodboy.loginIntent.action.main");
m_intent.addCategory(Intent.CATEGORY_DEFAULT);
startActivity(m_intent);
}
});
}
}
The source code of main.java
package com.goodboy.loginIntent;
import android.app.Activity;
import android.os.Bundle;
import com.goodboy.loginIntent.R;
public class main extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
The login layout:
<?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="vertical" >
<EditText
android:id="#+id/et_user"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10" >
<requestFocus />
</EditText>
<EditText
android:id="#+id/et_pwd"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPassword" />
<Button
android:id="#+id/btn_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
The java source code of evil activity:
package com.badboy.stealIntent;
import com.badboy.stealIntent.R;
import android.app.Activity;
import android.os.Bundle;
import android.widget.Toast;
public class BadIntentActivity extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Toast.makeText(getBaseContext(),
"username: "+this.getIntent().getStringExtra("username")+
"\npassword: "+this.getIntent().getStringExtra("password"),
Toast.LENGTH_SHORT).show();
}
}
Thanks #David Wasser, the manifest of login app(update):
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.goodboy.loginIntent"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="15" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".GoodloginActivity"
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=".main"
android:label="#string/main" >
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
The manifest of the badIntent:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.badboy.stealIntent"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="15" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".BadIntentActivity"
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>
You should take a look at Intent Intercept, an application aimed for developer which, as the name says, intercept any "public" Intent, allowing you to browse the intent setup and data. Intent Intercept is Open source, you can browse the code on GitHub
As for your problem, check that the BadBoy application is registered for the action you're using. Also, take a look at the stacktrace in logcat on goodlogin to see where the activity crashes.
You are probably getting an ActivityNotFoundException when you call startActivity() in GoodloginActivity because there is no Activity known to the system that responds to:
ACTION = "com.goodboy.loginIntent.action.main" and
CATEGORY = CATEGORY_DEFAULT
Have a look at your logcat output.
My app has three tabs, one of which is a Map. From the other two tabs I want the user to be able (after navigation through several screens) to go to the map tab and a certain location on the map with a button click from one of the screens which the user ends up on from the other two tabs. Is this possible?
referenced from method intentTest.xyz.com.intentTest$1.onClick
1.intentTest.java:
package intentTest.xyz.com;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class intentTest extends Activity {
Button b;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
b = (Button) findViewById(R.id.b);
b.setOnClickListener( new View.OnClickListener() {
public void onClick(View view) {
Intent intent = new Intent(intentTest.this,second.class );
startActivity(intent);
}
});
}
}
2.main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="First screen"
/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="map"
android:id="#+id/b"
/>
</LinearLayout>
3.second.java:
package intentTest.xyz.com;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import android.os.Bundle;
public class second extends MapActivity{
MapView map;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.second);
map = (MapView) findViewById(R.id.map);
}
#Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
4.second.xml:
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.maps.MapView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:apiKey="0ujyc9Tw2cYvyPECIKTQIK0pwuL-UPa_sh4BpIw"
/>
5.manifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="intentTest.xyz.com"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".intentTest"
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=".second"
android:label="#string/app_name">
<uses-library android:name="com.google.android.maps" />
</activity>
</application>
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
I am trying to transfer an int value between two activities using intents, but my app keeps crashing. When I comment out the transfer of any data and simply use an intent, everything seems to work. I cannot tell what is wrong.
Activity 1 (HeartRateActivity):
//Imports
public class HeartRateActivity extends Activity {
/** Called when the activity is first created. */
Button nextActivity;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
nextActivity = (Button)findViewById(R.id.nextActivity);
nextActivity.setOnClickListener(new Button.OnClickListener(){
#Override
public void onClick(View v) {
Intent intent = new Intent(HeartRateActivity.this, NextActivity.class);
intent.putExtra("age", 2);
startActivity(intent);
}
});
}
}
My NextActivity.java
package com.heartRate;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class NextActivity extends Activity {
TextView display;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.next);
int age = getIntent().getIntExtra("age", 0);
display = (TextView) findViewById(R.id.display);
display.setText(age);
}
}
My AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.heartRate" android:versionCode="1" android:versionName="1.0">
<uses-sdk android:minSdkVersion="7" />
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".HeartRateActivity"
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=".NextActivity"
android:label="#string/app_name" />
</application>
</manifest>
My main.xml (used by HeartRateActivity)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/hello"
/>
<Button android:layout_width="wrap_content" android:layout_height="wrap_content"
android:id="#+id/nextActivity" android:text="nextActivity"></Button>
</LinearLayout>
My next.xml(used by NextActivity) is similar and i dont think thats the issue...:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:text="TextView" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/display"></TextView>
</LinearLayout>
I would appreciate help in solving this issue! Thank you
Replace
display.setText(age);
with
display.setText(Integer.toString(age));
If you provide an int as a parameter, it uses it as a resource ID, which, in this case, obviously doesn't exist.
just try do like this.
display = (TextView) findViewById(R.id.display);
display.setText(Integer.toString(age));
and surely it will work
Make sure that your Id and Intent Destination all must be Ok.
then just put between intent from initialize ans start.
with put
intent.putExtra("age", Double);
from get this.
double d = getIntent().getStringExtra("age");
Make sure that R.id.display is a valid TextView in your next layout.
Just so we're clear, you're saying when you include the ...
intent.putExtra("age", 2);
in the sending Activity, and the ...
int age = getIntent().getIntExtra("age", 0);
in the receiving Activity, the application crashes or expereinces problems? And, by excluding those 2 statements the application performs normally? I'm just curious what does LogCat show? Even though you application is crashing LogCat will have several entries as to what was happening just prior to the close.
I am trying to access the google calendar using gdata. but the application closes :(
I have added gdata-client-1.0.jar as external jar.
here are my files :
rrr.java
package caleda.qwe;
import java.net.URL;
import com.google.gdata.client.calendar.CalendarService;
import com.google.gdata.data.calendar.CalendarEntry;
import com.google.gdata.data.calendar.CalendarFeed;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class rrr extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
String res="not proper";
// Create a CalenderService and authenticate
CalendarService myService = new CalendarService("calendar");
try{
myService.setUserCredentials("sunnycool333", "XXXXX");
// Send the request and print the response
URL feedUrl = new URL("https://www.google.com/calendar/feeds/default/owncalendars/full");
CalendarFeed resultFeed = myService.getFeed(feedUrl, CalendarFeed.class);
// System.out.println("Calendars you own:");
// System.out.println();
for (int i = 0; i < resultFeed.getEntries().size(); i++) {
CalendarEntry entry = resultFeed.getEntries().get(i);
// System.out.println("\t" + entry.getTitle().getPlainText());
res=entry.getTitle().getPlainText();
}
}
catch (Exception e) {
// TODO: handle exception
//System.out.println("not working");
res=e.toString();
}
TextView view = (TextView)findViewById(R.id.TextView01);
view.setText(res);
}
}
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/hello"
/>
<TextView android:text="#+id/TextView01" android:id="#+id/TextView01" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
</LinearLayout>
applicationmanifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="caleda.qwe"
android:versionCode="1"
android:versionName="1.0">
<uses-permission android:name="android.permission.INTERNET" />
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".rrr"
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>
Can someone please help me in pointing out my mistake.
Your Activity may be failing with the Application Not Responding dialog because you are making a network access on the UI thread.
Try using an AsyncTask.
This question has some example code and links concerning AsyncTask.
Thanks a lot everyone..
If we add two more files as external jar files the problem gets solved..
The two files are located in "deps" folder of gdata client src..
named : google-collect-1.0-rc1.jar & jsr305.jar