when i tried to run my app via eclipse !!!!!!! - Java for Android App Development

when i tried to run my app on HTC deesire using eclipse the message pops up ::::::
[2013-06-20 01:27:42 - IcsAsDef] Failed to install IcsAsDef.apk on device 'HT04GPL02764!
[2013-06-20 01:27:42 - IcsAsDef] (null)
[2013-06-20 01:27:42 - IcsAsDef] Launch canceled!

Please provide us more information.
Did you enable the USB debugging?

Hello
I will try to solve this problem as soon as, Thanks for posting. I would like to solve this. Good day.

nikwen said:
Please provide us more information.
Did you enable the USB debugging?
Click to expand...
Click to collapse
i have enabled it about year ago ......... when i rebooted the phone it works ... but
look i am a newbie in app creating
i am learning it now from this site http://developer.android.com/training/basics/firstapp/starting-activity.html
but when i run this step after learning it ... its just like the before
if u entered the site you will see ... that if u typed a message and pressed the formed bottom (send)
the message will be desplayed in the whole app screen
but when i run it .. and pressed the bottom it reamains as it is
sorry for my bad english .. but please be patient with me :good: :good:

ahmed_alaa said:
when i tried to run my app on HTC deesire using eclipse the message pops up ::::::
[2013-06-20 01:27:42 - IcsAsDef] Failed to install IcsAsDef.apk on device 'HT04GPL02764!
[2013-06-20 01:27:42 - IcsAsDef] (null)
[2013-06-20 01:27:42 - IcsAsDef] Launch canceled!
Click to expand...
Click to collapse
Try this:
Open a command prompt window and type 'adb kill-server' (Without quotation marks). When it's done, type 'adb start-server'
If that doesn't work, try restarting eclipse, your computer and your device. I've had this problem before, and usually one of these steps solves it.

ahmed_alaa said:
i have enabled it about year ago ......... when i rebooted the phone it works ... but
look i am a newbie in app creating
i am learning it now from this site http://developer.android.com/training/basics/firstapp/starting-activity.html
but when i run this step after learning it ... its just like the before
if u entered the site you will see ... that if u typed a message and pressed the formed bottom (send)
the message will be desplayed in the whole app screen
but when i run it .. and pressed the bottom it reamains as it is
sorry for my bad english .. but please be patient with me :good: :good:
Click to expand...
Click to collapse
So there is a second problem, too?! Please post your complete code. It could be that you missed one line.

no the first proplem has been solved when i rebooted the device
nikwen said:
So there is a second problem, too?! Please post your complete code. It could be that you missed one line.
Click to expand...
Click to collapse
no the first proplem has been solved when i rebooted the device ............ and thanks for help any way... i am talking now about the new one that in the second lesson i learned in the page that i have been shared it .... no thing happen when i press the (send) button i created its just like the first lesson (creating button without any respond to click ) .......... so which section of codes you need me to post it !!!!!

ahmed_alaa said:
no the first proplem has been solved when i rebooted the device ............ and thanks for help any way... i am talking now about the new one that in the second lesson i learned in the page that i have been shared it .... no thing happen when i press the (send) button i created its just like the first lesson (creating button without any respond to click ) .......... so which section of codes you need me to post it !!!!!
Click to expand...
Click to collapse
Please post your xml layouts and your two Activities.

ok
nikwen said:
Please post your xml layouts and your two Activities.
Click to expand...
Click to collapse
the activity_main.xml
?xml version="1.0" encoding="utf-8"?>
<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"
androidrientation="horizontal">
<EditText android:id="@+id/edit_message"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="@string/edit_message" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_send"
androidnClick="sendMessage" />
</LinearLayout>
activity_display_message
<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"
androidaddingBottom="@dimen/activity_vertical_margin"
androidaddingLeft="@dimen/activity_horizontal_margin"
androidaddingRight="@dimen/activity_horizontal_margin"
androidaddingTop="@dimen/activity_vertical_margin"
tools:context=".DisplayMessageActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
</RelativeLayout>
thnx for your caring am just a noob in creating apps ... and i wish to be better with your assist

ahmed_alaa said:
the activity_main.xml
?xml version="1.0" encoding="utf-8"?>
<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"
androidrientation="horizontal">
<EditText android:id="@+id/edit_message"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="@string/edit_message" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_send"
androidnClick="sendMessage" />
</LinearLayout>
activity_display_message
<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"
androidaddingBottom="@dimen/activity_vertical_margin"
androidaddingLeft="@dimen/activity_horizontal_margin"
androidaddingRight="@dimen/activity_horizontal_margin"
androidaddingTop="@dimen/activity_vertical_margin"
tools:context=".DisplayMessageActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
</RelativeLayout>
thnx for your caring am just a noob in creating apps ... and i wish to be better with your assist
Click to expand...
Click to collapse
oh i am sorry for that emotions all the is : D AND ALL THE is : P i think you know that

others...
ahmed_alaa said:
oh i am sorry for that emotions all the is : D AND ALL THE is : P i think you know that
Click to expand...
Click to collapse
DisplayMessageActivity.java
package com.example.icsasdef;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;
public class DisplayMessageActivity extends Activity {
@override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Get the message from the intent
Intent intent = getIntent();
String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
// Create the text view
TextView textView = new TextView(this);
textView.setTextSize(40);
textView.setText(message);
// Set the text view as the activity layout
setContentView(textView);
}
}
MainActivity.java
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.content.Intent;
import android.widget.EditText;
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;
}
public final static String EXTRA_MESSAGE = "com.example.myfirstapp.MESSAGE";
/** Called when the user clicks the Send button */
public void sendMessage(View view) {
// Do something in response to button
Intent intent = new Intent(this, DisplayMessageActivity.class);
EditText editText = (EditText) findViewById(R.id.edit_message);
String message = editText.getText().toString();
intent.putExtra(EXTRA_MESSAGE, message);
}
}

oh i found the missed line
ahmed_alaa said:
oh i am sorry for that emotions all the is : D AND ALL THE is : P i think you know that
Click to expand...
Click to collapse
the missed line was here
in MainActivity.java
i missed that line
startActivity(intent);
ty so much that you noticed me to search about the missed line .........

Related

Unable to compile android project in eclipse [r.java]

Hi ,
when i try to create project in eclipse i always getting this error that R.java is not found.
When i hit crtl+shf+O to import but still getting error :
Code:
package com.example.test;
import android.R;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list);
}
@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;
}
}
getting error :
activity_main cannot be resolved or is not a field MainActivity.java /test/src/com/example/test line 13 Java Problem
activity_main.xml
Code:
<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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
</RelativeLayout>
Get rid of the import android.R, then compile...
Sent from my NexusHD2 using xda premium
shanman-2 said:
Get rid of the import android.R, then compile...
Sent from my NexusHD2 using xda premium
Click to expand...
Click to collapse
When i remove the import android.R
and clean it and build it again , i got the following errors:
activity_list cannot be resolved or is not a field MainActivity.java /test/src/com/example/test line 13 Java Problem
main cannot be resolved or is not a field MainActivity.java /test/src/com/example/test line 19 Java Problem
shanalikhan said:
Hi ,
when i try to create project in eclipse i always getting this error that R.java is not found.
When i hit crtl+shf+O to import but still getting error :
Code:
package com.example.test;
import android.R;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list);
}
@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;
}
}
getting error :
activity_main cannot be resolved or is not a fieldMainActivity.java/test/src/com/example/testline 13Java Problem
activity_main.xml
Code:
<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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
</RelativeLayout>
Click to expand...
Click to collapse
Change the line setContentView to target to
R.layout.activity_main
Sent from my NexusHD2 using xda premium
shanman-2 said:
Change the line setContentView to target to
R.layout.activity_main
Sent from my NexusHD2 using xda premium
Click to expand...
Click to collapse
Hi ,
now im getting these error :
R cannot be resolved to a variable MainActivity.java /test/src/com/example/test line 13 Java Problem
R cannot be resolved to a variable MainActivity.java /test/src/com/example/test line 19 Java Problem
package com.example.test;
import android.app.Activity;
import android.os.Bundle;
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.main, menu);
return true;
}
}
Check your code, there is an error in your XML file!!!!
Hint: line of repeated code near the start...
One thing to learn about coding is... debugging is a big part of it.
Learn how to use logcat and other adb stuff
Sent from my NexusHD2 using xda premium
shanman-2 said:
Check your code, there is an error in your XML file!!!!
Hint: line of repeated code near the start...
One thing to learn about coding is... debugging is a big part of it.
Learn how to use logcat and other adb stuff
Sent from my NexusHD2 using xda premium
Click to expand...
Click to collapse
actually the project donot run so im able to debug , can you tell me where the error is
main.xml
Code:
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:showAsAction="never"
android:title="@string/action_settings"/>
</menu>
activity_main.xml
Code:
<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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
</RelativeLayout>
anyone please reply !
shanalikhan said:
anyone please reply !
Click to expand...
Click to collapse
Do you see the 'gen' folder with your same package inside, com.example.test?
Have you tried a Project ->Clean->All projects? I would also recommend Project->Build automatically

[HELP][NEWBIE]Camera Activity Not working...

Hi people, I am newbie , trying to learn android developing.
So i was making this app. which uses the camera client android clicks a picture and then sets it as wallpaper, as per the user's request.
But when i try to install it on my phone (Samsung Galaxy y duos ). It says application not installed. I am not able to understand why. I have also added the permissions on the Android manifest. Please do help me out. I will be attaching the xml for the camera app and its Class.
THE JAVA CLASS...
Code:
package com.example.done;
import java.io.IOException;
import java.io.InputStream;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
public class Camera extends Activity implements View.OnClickListener {
Button camera;
ImageButton done;
ImageView wallpaper;
int cameraData = 0;
Intent i;
Bitmap pic;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.photo);
intial();
camera.setOnClickListener(this);
done.setOnClickListener(this);
InputStream is = getResources().openRawResource(R.drawable.abc);
pic= BitmapFactory.decodeStream(is);
int cameraData = 0;
Intent i;
}
private void intial() {
// TODO Auto-generated method stub
camera = (Button) findViewById(R.id.camera);
done = (ImageButton) findViewById(R.id.imgTile);
wallpaper = (ImageView) findViewById(R.id.imagButt);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.camera:
i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(i, cameraData);
break;
case R.id.imagButt:
try {
getApplicationContext().setWallpaper(pic);
} catch (IOException e) {
e.printStackTrace();
}
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK) {
Bundle e = i.getExtras();
pic = (Bitmap) e.get("data");
wallpaper.setImageBitmap(pic);
}
}
}[/CODE]
the Xml file (photo.xml)
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="xda wont allow"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/imgTile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/abc"
android:layout_gravity="center" />
<ImageButton
android:id="@+id/imagButt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/ic_launcher" />
<Button
android:id="@+id/camera"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Button" />
</LinearLayout>
ThankYou in advance
Please add your manifest to the OP too, the issue is most likely in it (The first thing that comes to my mind is that your app has a higher android:minSdkVersion than your device's version of android)
Also, did you export a signed apk?
Are you using Eclipse ?
If you do, just make a right click on your project name and choose "Run As --> Android Application" to launch it on your connected device with adb enabled.
If you want to export a signed apk, right click your project's name and choose "Android tools --> Export Signed Application Package..." and follow the instructions in the daemon.
Manifest
Androguide.fr said:
Please add your manifest to the OP too, the issue is most likely in it (The first thing that comes to my mind is that your app has a higher android:minSdkVersion than your device's version of android)
Also, did you export a signed apk?
Are you using Eclipse ?
If you do, just make a right click on your project name and choose "Run As --> Android Application" to launch it on your connected device with adb enabled.
If you want to export a signed apk, right click your project's name and choose "Android tools --> Export Signed Application Package..." and follow the instructions in the daemon.
Click to expand...
Click to collapse
Yeah i am on eclipse.
And yup I am using a signed APK.
Actually, if i hit run. It would start up my emulator(It is installng on that perfectly).
But i have not connected my emulator to the webcam, so it would forceClose.
I have also set my emulator to Qvga.
And yup, the i have attached the manifest too.:good::good:
Manifest
Androguide.fr said:
Please add your manifest to the OP too, the issue is most likely in it (The first thing that comes to my mind is that your app has a higher android:minSdkVersion than your device's version of android)
Also, did you export a signed apk?
Are you using Eclipse ?
If you do, just make a right click on your project name and choose "Run As --> Android Application" to launch it on your connected device with adb enabled.
If you want to export a signed apk, right click your project's name and choose "Android tools --> Export Signed Application Package..." and follow the instructions in the daemon.
Click to expand...
Click to collapse
Yeah i am on eclipse.
And yup I am using a signed APK.
Actually, if i hit run. It would start up my emulator(It is installng on that perfectly).
But i have not connected my emulator to the webcam, so it would forceClose.
I have also set my emulator to Qvga.
And yup, the i have attached the manifest too.:good::good:
Actually the app i am developing, includes a menu which includes some other apps. Everything other app was working fine, until i added the camera app. . If you want the classes of the other apps, I can provide you that. But please help me. Thanks
Code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.done"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="8" />
<uses-permission android:name="android.permission.SET_WALLPAPER" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".Splash"
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.done.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.example.done.MAINACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".Menu"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.example.done.MENU" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".Password"
android:label="@string/app_name" >
</activity>
<activity
android:name=".Email"
android:label="@string/app_name" >
</activity>
<activity
android:name=".Camera"
android:label="cameraApp"
android:screenOrientation="portrait" >
</activity>
</application>
</manifest>
Add this permission to your manifest :
Code:
<uses-permission android:name="android.permission.CAMERA"/>
What version of Android is your device running ? You might wanna change this line
Code:
android:targetSdkVersion="8"
to :
Code:
android:targetSdkVersion="17"
if you want your app to support devices running ics & jellybean and/or be able to use the latest APIs (download the android 4.2.2 sdk platform if eclipse throws an error)
EDIT : you also have a whitespace in this line, remove it :
Code:
i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CA [COLOR="DarkRed"]here [/COLOR]PTURE
It would be helpful if you paste in here the output of the console. It has nothing to do with the java code since it is being installed in the emulator.
Still not working
Androguide.fr said:
Add this permission to your manifest :
Code:
<uses-permission android:name="android.permission.CAMERA"/>
What version of Android is your device running ? You might wanna change this line
Code:
android:targetSdkVersion="8"
to :
Code:
android:targetSdkVersion="17"
if you want your app to support devices running ics & jellybean and/or be able to use the latest APIs (download the android 4.2.2 sdk platform if eclipse throws an error)
EDIT : you also have a whitespace in this line, remove it :
Code:
i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CA [COLOR="DarkRed"]here [/COLOR]PTURE
Click to expand...
Click to collapse
As you said, i made all the changes. (Includind premissions etc.)
But it is not working.
When i run it on my emulator, it is getting installed. But when i run it on my phone.. It says app not installed.
Also I am attchiing the console output.
[2013-04-16 12:49:11 - Emulator] emulator: WARNING: Could not initialize OpenglES emulation, using software renderer.
[2013-04-16 12:49:12 - done] New emulator found: emulator-5554
[2013-04-16 12:49:12 - done] Waiting for HOME ('android.process.acore') to be launched...
[2013-04-16 12:50:09 - done] HOME is up on device 'emulator-5554'
[2013-04-16 12:50:09 - done] Uploading done.apk onto device 'emulator-5554'
[2013-04-16 12:50:35 - done] Installing done.apk...
[2013-04-16 12:50:57 - done] Success!
[2013-04-16 12:50:57 - done] Starting activity com.example.done.Splash on device emulator-5554
[2013-04-16 12:51:00 - done] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.done/.Splash }
hiphop12ism said:
As you said, i made all the changes. (Includind premissions etc.)
But it is not working.
When i run it on my emulator, it is getting installed. But when i run it on my phone.. It says app not installed.
Also I am attchiing the console output.
[2013-04-16 12:49:11 - Emulator] emulator: WARNING: Could not initialize OpenglES emulation, using software renderer.
[2013-04-16 12:49:12 - done] New emulator found: emulator-5554
[2013-04-16 12:49:12 - done] Waiting for HOME ('android.process.acore') to be launched...
[2013-04-16 12:50:09 - done] HOME is up on device 'emulator-5554'
[2013-04-16 12:50:09 - done] Uploading done.apk onto device 'emulator-5554'
[2013-04-16 12:50:35 - done] Installing done.apk...
[2013-04-16 12:50:57 - done] Success!
[2013-04-16 12:50:57 - done] Starting activity com.example.done.Splash on device emulator-5554
[2013-04-16 12:51:00 - done] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.done/.Splash }
Click to expand...
Click to collapse
You're giving us the output for the emulator here... We need to see the output for when you install it on an actual device as it's where your problem is.
I attached a screenshot.
I hope that helps.
So as i told you, everything was working fine. Until i added the camera app. But for experiment's sake, i deleted the app's xml, java and the activity from the manifest. But still the same result.
As i.told you, the camera app is a sub app in my phone..
The whole app contains some more app. But even then its not working:thumbup::thumbup:
Sent from my GT-S6102 using xda app-developers app
Problem Solved
Hey fellas.
I thought that changing the phone, would solve the problem,
So i used samsung s2 instead of samasing galaxy y duos.
And the app worked....
But i am not able to determine the reason.
Why don't you post the output of the console? You have been asked several times :good:
You will not find anything in the console.
As eclipse installes the apk in my emulator. In the emulator, it installs perfectly. So everything in the console is positve. Anyways i have already attached the console output in the previous page. And if you need the logcat. I will provide you.
Anyways, a great thanks for your concern
--------+---------+-----------+-------------
Sent from my GT-S6102 using xda app-developers app
Could you provide us your android manifest?
Maybe you need to set a lower minSdkVersion. (Although it says "Parsing error" on my Samsung Galaxy Ace if there is a wrong minSdkVersion)
I have copied the manifest in the previous page. I have tried putting minsdk on qvga adpi.
But it didnt work..
Sent from my GT-S6102 using xda app-developers app
hiphop12ism said:
I have copied the manifest in the previous page. I have tried putting minsdk on qvga adpi.
But it didnt work..
Sent from my GT-S6102 using xda app-developers app
Click to expand...
Click to collapse
Ah. Ok. Thanks.
The minSdkVersion is the minimum Android version which has to be installed on the device.
8 is the code for Android 2.2.
Which Android version is running on your device? Maybe you will need to set it to a lower value.
i have 2.3.6
Sent from my GT-S6102 using xda app-developers app

[Q] ListView with BaseAdapter not showing

Hi I have used ListFragment and simple ArrayAdapter quite often. And now I want to try some more by customizing BaseAdapter. But something happened, the List is not showing at all. I don't have any error (the Logcat also saying there're no error). But I debug it, and found out that getView() in my customized BaseAdapter is not called. I wonder why?
Here's the snippet:
#favorite_list_layout
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent">
<ListView
android:id="@+id/favorite_list"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
#favorite_list_item
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/favorite_text"
android:layout_margin="5dp"
android:layout_marginLeft="10dp"
android:layout_marginBottom="0dp"
android:textSize="35sp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/favorite_text_details"
android:layout_marginLeft="10dp"
android:layout_marginTop="0dp"
android:layout_marginBottom="5dp"
android:fontFamily="sans-serif-light"
android:textSize="18sp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
#FavoritesFragment
Code:
public class FavoritesFragment extends ListFragment {
[user=439709]@override[/user]
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
//... setting variable favList, and this code is working. favList is not empty and there're no error
setListAdapter(new FavoriteAdapter(getActivity(), favList));
}
}
FavoriteAdapter, extends BaseAdapter
Code:
public class FavoriteAdapter extends BaseAdapter {
private Context ctx;
List<DMapData> list;
public FavoriteAdapter(Context context, List<DMapData> list) {
this.ctx = context;
this.list = list;
System.out.println("constructor executed!");
}
[user=439709]@override[/user]
public int getCount() {
return list.size();
}
[user=439709]@override[/user]
public Object getItem(int i) {
return list.get(i);
}
[user=439709]@override[/user]
public long getItemId(int i) {
return i;
}
[user=439709]@override[/user]
public View getView(int position, View convertView, ViewGroup parent) {
System.out.println("GetView is executed"); //But it's not.
View rowView = convertView;
if (rowView == null) {
LayoutInflater inflater = (LayoutInflater) ctx
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
rowView = inflater.inflate(R.layout.favorite_list_item, parent, false);
}
TextView favText = (TextView) rowView.findViewById(R.id.favorite_text);
TextView detailsText = (TextView) rowView.findViewById(R.id.favorite_text_details);
DMapData data = list.get(position);
System.out.println("DMapData from List");
favText.setText(data.getName());
detailsText.setText(data.getDetails().length()<=50? data.getDetails() : data.getDetails().substring(0, 51).concat("..."));
System.out.println("At the end of getView()");
return rowView;
}
}
Thanks
The id of the ListView has to be a special one so that the ListFragment can find it:
Code:
android:id="@android:id/list"
Hmm...
I have tried to change the id like your code. But, still not shown up. Is there anything I should do with my ListFragment?
nikwen said:
The id of the ListView has to be a special one so that the ListFragment can find it:
Code:
android:id="@android:id/list"
Click to expand...
Click to collapse
JoshieGeek said:
Hmm...
I have tried to change the id like your code. But, still not shown up. Is there anything I should do with my ListFragment?
Click to expand...
Click to collapse
Do you inflate your layout?
Code:
[user=439709]@override[/user]
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_layout, container, false);
}
I always set the adapter in onCreate but there shouldn't be a difference.
Your layout looks like that now, right?
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent">
<ListView
android:id="android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
EDIT: Oh, add an orientation to the LinearLayout or replace it by a RelativeLayout.
And change the ListView heigth to match_parent.
Yupz. But still no different.
Here's my changed code. I have changed not using my customized adapter again, but instead using SimpleAdapter.
/res/layout/favorite_list_layout.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent">
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
/res/layout/favorite_list_item
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/favorite_text"
android:layout_margin="5dp"
android:layout_marginLeft="10dp"
android:layout_marginBottom="0dp"
android:textSize="35sp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/favorite_text_details"
android:layout_marginLeft="10dp"
android:layout_marginTop="0dp"
android:layout_marginBottom="5dp"
android:fontFamily="sans-serif-light"
android:textSize="18sp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
/src/.../AllFragment.java
Code:
public class AllFragment extends ListFragment {
[user=439709]@override[/user]
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//TODO get All Data
//Let's just adopt Favorite List Adapter for now
MasterDataReader mdReader = new MasterDataReader();
mdReader.execute();
List<DMapData> allList = new ArrayList<DMapData>();
allList.add(new DMapData("Empty", "No data found!"));
try {
allList = mdReader.get();
System.out.println("All List received");
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
List<Map<String, String>> finList = new ArrayList<Map<String, String>>();
for(DMapData data : allList) {
Map<String, String> m = new HashMap<String, String>();
m.put("name", data.getName());
m.put("detail", data.getDetails().length()<=50? data.getDetails() : data.getDetails().substring(0, 51).concat("..."));
finList.add(m);
}
String[] colNames = new String[] {
"name", "detail"
};
int[] tView = new int[] {
R.id.favorite_text, R.id.favorite_text_details
};
SimpleAdapter simpleAdapter = new SimpleAdapter(getActivity(), finList, R.layout.favorite_list_layout,
colNames, tView);
setListAdapter(simpleAdapter);
}
[user=439709]@override[/user]
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.favorite_list_layout, container, false);
}
}
What do you think?
nikwen said:
Do you inflate your layout?
Code:
[user=439709]@override[/user]
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_layout, container, false);
}
I always set the adapter in onCreate but there shouldn't be a difference.
Your layout looks like that now, right?
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent">
<ListView
android:id="android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
EDIT: Oh, add an orientation to the LinearLayout or replace it by a RelativeLayout.
And change the ListView heigth to match_parent.
Click to expand...
Click to collapse
JoshieGeek said:
Yupz. But still no different.
Here's my changed code. I have changed not using my customized adapter again, but instead using SimpleAdapter.
/res/layout/favorite_list_layout.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent">
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
/res/layout/favorite_list_item
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/favorite_text"
android:layout_margin="5dp"
android:layout_marginLeft="10dp"
android:layout_marginBottom="0dp"
android:textSize="35sp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/favorite_text_details"
android:layout_marginLeft="10dp"
android:layout_marginTop="0dp"
android:layout_marginBottom="5dp"
android:fontFamily="sans-serif-light"
android:textSize="18sp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
/src/.../AllFragment.java
Code:
public class AllFragment extends ListFragment {
[user=439709]@override[/user]
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//TODO get All Data
//Let's just adopt Favorite List Adapter for now
MasterDataReader mdReader = new MasterDataReader();
mdReader.execute();
List<DMapData> allList = new ArrayList<DMapData>();
allList.add(new DMapData("Empty", "No data found!"));
try {
allList = mdReader.get();
System.out.println("All List received");
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
List<Map<String, String>> finList = new ArrayList<Map<String, String>>();
for(DMapData data : allList) {
Map<String, String> m = new HashMap<String, String>();
m.put("name", data.getName());
m.put("detail", data.getDetails().length()<=50? data.getDetails() : data.getDetails().substring(0, 51).concat("..."));
finList.add(m);
}
String[] colNames = new String[] {
"name", "detail"
};
int[] tView = new int[] {
R.id.favorite_text, R.id.favorite_text_details
};
SimpleAdapter simpleAdapter = new SimpleAdapter(getActivity(), finList, R.layout.favorite_list_layout,
colNames, tView);
setListAdapter(simpleAdapter);
}
[user=439709]@override[/user]
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.favorite_list_layout, container, false);
}
}
What do you think?
Click to expand...
Click to collapse
Try this layout:
Code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@android:id/list"
android:layout_alignParentTop="true"
android:fastScrollEnabled="true" />
<ProgressBar
android:id="@android:id/empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
style="?android:attr/progressBarStyle" />
</RelativeLayout>
It's working for me.
Did you try to write all entries to the logs? Do you get an output?
You know what? This is really make me laugh all the time, that it's because what I think is right but actually not. The list that I provided for my ListView is actually empty. Your layout tell me, because there's always the progressbar. Thank you very much for your help. :highfive:
nikwen said:
Try this layout:
Code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@android:id/list"
android:layout_alignParentTop="true"
android:fastScrollEnabled="true" />
<ProgressBar
android:id="@android:id/empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
style="?android:attr/progressBarStyle" />
</RelativeLayout>
It's working for me.
Did you try to write all entries to the logs? Do you get an output?
Click to expand...
Click to collapse
JoshieGeek said:
You know what? This is really make me laugh all the time, that it's because what I think is right but actually not. The list that I provided for my ListView is actually empty. Your layout tell me, because there's always the progressbar. Thank you very much for your help. :highfive:
Click to expand...
Click to collapse
Welcome.
I'm glad that you solved that because it began to drive me crazy. :laugh:
@JoshieGeek
consider using Log
Log.i("class/functionName","message you want to display");
Click to expand...
Click to collapse
It will be easy to debug
Sandeep_Jagtap said:
@JoshieGeek
consider using Log
It will be easy to debug
Click to expand...
Click to collapse
Didn't you see that he already solved his problem?
nikwen said:
Didn't you see that he already solved his problem?
Click to expand...
Click to collapse
Yes its quite noticeable
As he was saying he could not see error in Log while debugging. My advice to use log was for his future projects.
Sent from my Incredible S using xda app-developers app
Sandeep_Jagtap said:
Yes its quite noticeable
As he was saying he could not see error in Log while debugging. My advice to use log was for his future projects.
Sent from my Incredible S using xda app-developers app
Click to expand...
Click to collapse
OK.
Check out my guide on debugging here: http://forum.xda-developers.com/showthread.php?t=2325164

[q]Problems with webview

Here are the problems
1.progressbar doesnt shows up even toast is showing
2.toast vanishes after 47%
3.actionbar doesnt hides as expected
4.how to make an update method so that when user clicks link progressbar again starts from 0-100
Code:
package com.me.myblog;
import android.app.*;
import android.os.*;
import android.view.*;
import android.webkit.*;
import android.widget.*;
public class MainActivity extends Activity
{WebView mWebView;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mWebView = (WebView) findViewById(R.id.activity_main_webview);
WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
mWebView.setWebViewClient(new WebViewClient());
ProgressBar p=(ProgressBar) findViewById(R.id.p);
mWebView.loadUrl("http://www.samsunggalaxyminiroms.blogspot.com");
for(double i=0.0;i<=mWebView.getProgress();i++){Toast.makeText(MainActivity.this,"loading \n"+i+"%",5000).show();p.setProgress(Math.round(Math.round(i)));if(i>=50.0){requestWindowFeature(Window.FEATURE_NO_TITLE);}}
}@Override // Detect when the back button is pressed
public void onBackPressed() { if(mWebView.canGoBack()) { mWebView.goBack(); } else { // Let the system handle the back button
super.onBackPressed();
} }
}
Code:
<?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" >
<ProgressBar
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:id="@+id/p"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<WebView android:id="@+id/activity_main_webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</RelativeLayout>
Sent from my GT-S5570 using XDA Premium 4 mobile app
Problems solved
Another problem
Is it possible to load posts of blog in cards ui?if yes how?
Sent from my GT-S5570 using XDA Premium 4 mobile app

[Q] How can custom tab view be implemented using setCustomTabView method

I am using Android's SlidingTabColors sample in my application layout. I have three tabs initialized. Due to the default tab layout all the tabs have same layout. I have searched everything about setCustomTabView; but unable to get it implemented. I wanted to know where should i call this method? What statements are to be used? I have used a switch statement in the onViewCreated method of the ContentFragment class. The code I have written in the onViewCreated method is posted below:
Code:
public void onViewCreated(View view, Bundle savedInstanceState)
{
super.onViewCreated(view, savedInstanceState);
TextView title = (TextView) view.findViewById(R.id.item_title);
int indicatorColor = args.getInt(KEY_INDICATOR_COLOR);
switch (indicatorColor)
{
case Color.RED:
{
SlidingTabLayout mSlidingTabLayout = (SlidingTabLayout) view.findViewById(R.id.sliding_tabs);
mSlidingTabLayout.setCustomTabView(R.layout.speed_test, R.id.hello1);
}
case Color.GREEN:
title.setText("Subject: " + args.getCharSequence(KEY_TITLE));
case Color.BLUE:
title.setText("Header: " + args.getCharSequence(KEY_TITLE));
}
}
[CODE]
The speed_test.xml file is posted below:
[CODE]
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Hello"
android:id="@+id/hello1"
/>
</RelativeLayout>
[CODE]

Categories

Resources