Android Emulator debugging Google Maps Eclipse app - android

I'm attempting to run an android app using the Google Api's library and am receiving a Failure to launch error when debugging upon entering an address into the input field.
Here is the error: http://s1278.beta.photobucket.com/user/cetmrw791346/media/wdyl_zps08bbe17f.png.html?sort=3&o=0
and
Here are the relevant files:
AWhereDoYouLive.java
package com.example.wheredoyoulive;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class AWhereDoYouLive extends Activity {
#Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
final AlertDialog.Builder adb = new AlertDialog.Builder(this);
final EditText addressfield = (EditText) findViewById(R.id.address);
final Button button = (Button) findViewById(R.id.launchmap);
button.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
try {
// Perform action on click
String address = addressfield.getText().toString();
address = address.replace(' ', '+');
Intent geoIntent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("geo:0,0?q=" + address));
startActivity(geoIntent);
} catch (Exception e) {
AlertDialog ad = adb.create();
ad.setMessage("Failed to Launch");
ad.show();
}
}
});
}
}
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="wrap_content"
android:layout_height="wrap_content"
android:text="Please enter your home address."
/>
<EditText
android:id="#+id/address"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:autoText="true"
/>
<Button
android:id="#+id/launchmap"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Show Map"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Unlocking Android, Chapter 1."
/>
</LinearLayout>
AndroidMainfest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.wheredoyoulive"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/icon" >
<activity android:label="#string/app_name"
android:name="com.example.wheredoyoulive.AWhereDoYouLive">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
<users-permission android:name="android.permission.INTERNET" />
</manifest>

When double-checking the Google services setup page: http://developer.android.com/google/play-services/setup.html it looks as if Google Play services isn’t supported by any of the available Android emulators.

There is a work around to make a Google Map API V2 to work on your emulator, please read the second part of the following blog post I wrote for more information:
Google Map API V2 in Emulator

Related

Why placing a call programatically gives error message "Internet Calling not Supported"?

This is my code:
public String a_number;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_make_the_call);
//
callButton = (ImageButton)findViewById(R.id.call_button);
aCall = (TextView)findViewById(R.id.number_a);
a_number = aCall.getText().toString();
}
public void makeCallFunction(View view) {
String temp = "";
temp = "tel:"+a_number;
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse(temp));
startActivity(callIntent);
}
My XML file contains:
<ImageButton
android:id="#+id/call_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:src="#drawable/dial"
android:onClick="makeCallFunction"/>
I have added the following in my manifest file:
<uses-permission android:name="android.permission.CALL_PHONE"/>
I searched my best for answers but found nothing helpful..
EDIT:
When I give a value directly, the call gets placed now.
Eg:
callIntent.setData(Uri.parse("tel:9876543210"));
But the problem remains when I read the number from my text view and try to place call with that number.
Can someone help me out?
Thanks in advance
If there's some alternate way to implement call, that'd help too.
Disable SIP Internet Calling and VoIP on your emulator or debugging device. This is the steps for Samsung Galaxy S4 :
go to settings > call > disable internet calling(in bottom)
I don't know what you are doing wrong, but see for yourself a working example :
MakeTheCallActivity.java
package com.example.makethecall;
import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class MakeTheCallActivity extends ActionBarActivity {
private EditText mEditText;
private Button mButton;
private final String TAG = "MakeTheCallActivity";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_make_the_call);
mButton = (Button)findViewById(R.id.call_button);
mButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
mEditText = (EditText)findViewById(R.id.phone_number);
String phoneNumber = mEditText.getText().toString();
Log.d(TAG, phoneNumber);
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phoneNumber));
startActivity(intent);
}
});
}
}
activity_make_the_call.xml
<LinearLayout 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" tools:context=".MakeTheCallActivity"
android:orientation="vertical">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/phone_number" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="call"
android:id="#+id/call_button" />
</LinearLayout>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.sauravsamamt.makethecall" >
<uses-permission android:name="android.permission.CALL_PHONE" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MakeTheCallActivity"
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 can see I'm not using a hardcoded number. Make sure you enter a valid number. That's it.

My application is stopped when executed. Error in my manifest?

My application is stopped when executed. I'm starting to program for android, just put a background and buttons, but it seems that I have problems creating the manifest. Before this project had many problems creating a new eclipse I put an activity together with the library and I started appcontainer_v7 errenter code hereored. To use the SDK 19 I decided to do everything manually.
CLASS:
package com.progra.cubebreaker;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
public class Menu extends Activity implements OnClickListener{
Button Jugar, Puntuaciones, Instrucciones;
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_menu);
Jugar.findViewById(R.id.btJugar);
Puntuaciones.findViewById(R.id.btInstrucciones);
Instrucciones.findViewById(R.id.btInstrucciones);
Jugar.setOnClickListener(this);
Puntuaciones.setOnClickListener(this);
Instrucciones.setOnClickListener(this);
}
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.btJugar:
break;
case R.id.btPuntuaciones:
Toast text = Toast.makeText(this, "Pendiente...", Toast.LENGTH_SHORT);
text.show();
break;
case R.id.btInstrucciones:
Toast text1 = Toast.makeText(this, "Pendiente...", Toast.LENGTH_SHORT);
text1.show();
break;
}
}
}
LAYOUT:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#drawable/fondo1" >
<Button
android:id="#+id/btInstrucciones"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignRight="#+id/btPuntuaciones"
android:layout_marginBottom="89dp"
android:text="#string/instrucciones"
android:textSize="40dp"
android:textStyle="italic|normal|bold" />
<Button
android:id="#+id/btPuntuaciones"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/btInstrucciones"
android:layout_centerHorizontal="true"
android:layout_marginBottom="60dp"
android:text="#string/puntuaciones"
android:textSize="40dp"
android:textStyle="italic|normal|bold" />
<Button
android:id="#+id/btJugar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/btPuntuaciones"
android:layout_centerHorizontal="true"
android:layout_marginBottom="66dp"
android:text="#string/jugar"
android:textColorHint="#android:color/background_dark"
android:textSize="40dp"
android:textStyle="italic|normal|bold" />
</RelativeLayout>
MANIFEST:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.progra.cubebreaker"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="19" />
<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>
</application>
</manifest>
You are not mapping the layout objects to java class objects thats y ur application is crashing.
You need to map the java button by converting id of button or any other attribute to (Button) etc.
Modify your code :
Jugar = (Button) findViewById(R.id.btInstrucciones);
Puntuaciones= (Button) findViewById(R.id.btPuntuaciones);
Instrucciones = (Button) findViewById(R.id.btInstrucciones);
Hope that helps.
just replace this code,
Jugar.findViewById(R.id.btJugar);
Puntuaciones.findViewById(R.id.btInstrucciones);
Instrucciones.findViewById(R.id.btInstrucciones);
by
Jugar = (Button) findViewById(R.id.btJugar);
Puntuaciones = (Button) findViewById(R.id.btPuntuaciones);
Instrucciones = (Button) findViewById(R.id.btInstrucciones);
Your application is crashing as you are not initializing the widgets in your code.
Here is the error:
Jugar.findViewById(R.id.btJugar);
Puntuaciones.findViewById(R.id.btInstrucciones);
Instrucciones.findViewById(R.id.btInstrucciones);
Change it to:
Jugar = (Button) findViewById(R.id.btJugar);
Puntuaciones = (Button) findViewById(R.id.btPuntuaciones);
Instrucciones = (Button) findViewById(R.id.btInstrucciones);

Is that possible to steal the message sent by Intents?

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.

Cannot seem to get the buttons to open a new MapActivity

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));
}
});

android google calendar .. application force 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

Categories

Resources