Unable to send and receive from DB through PHP - Java for Android App Development

Hi,
I am unable get the value my json to my settext. I have tried it but I am getting null please let know how to solve it.
try
{
// Checking for SUCCESS TAG
int success = json.getInt(TAG_SUCCESS);
if (success == 1)
{
Questions = json.getJSONArray(TAG_Questions);
Log.d("users_list.length() : ", String.valueOf( Questions.length()));
for (int i = 0; i < Questions.length(); i++)
{
JSONObject c = Questions.getJSONObject(i);
Quensstring = c.getString("question" + i);
}
// JSONObject ques = new JSONObject();
// Quens = ques.getString("question");
}
else
{
// no products found
// Launch Add New product Activity
Intent i = new Intent(getApplicationContext(),
day1q1.class);
// Closing all previous activities
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
}
} catch (JSONException e) { e.printStackTrace(); }
return null;
}
protected void onPostExecute(String file_url)
{
dialog.dismiss();
runOnUiThread(new Runnable()
{
public void run()
{
System.out.println("usersMap.get(User1) : " + Quensstring[0]);
User1.setText(Quensstring[0]);
}
});
}/INDENT]​
My json is {"success":1,"question":[{"question":"Question2"}]}
so please help how to solve this​

First: System.out.println(); Doesnt work in android because it doesnt work on console to print the output. You have to do all output graphically with TextView.
To answer your question, you say, you get your question from a remote server. So did you add
Code:
<uses-permission android:name="android.permission.INTERNET" />
to your manifest to successfully connect to internet and get data?

reply
vijai2011 said:
First: System.out.println(); Doesnt work in android because it doesnt work on console to print the output. You have to do all output graphically with TextView.
To answer your question, you say, you get your question from a remote server. So did you add
Code:
<uses-permission android:name="android.permission.INTERNET" />
to your manifest to successfully connect to internet and get data?
Click to expand...
Click to collapse
First System.out.printin() was working fine for I am able to see the Output on the console.
Second I have added the Internet Permissions in the manifesto.

What is the error? Can you get a logcat?
Sent from my SGH-I337M using xda app-developers app

alobo said:
What is the error? Can you get a logcat?
Sent from my SGH-I337M using xda app-developers app
Click to expand...
Click to collapse
Thank you I got still more new way to do but. I will know the problem in my way because I need to used this in later on.
So please to solve this. I have Got the value null that is it I have got the error.

raja_king said:
First System.out.printin() was working fine for I am able to see the Output on the console.
Second I have added the Internet Permissions in the manifesto.
Click to expand...
Click to collapse
I meant in android phone. Not your eclipse logcat console. All System.out.print are directed to logcat in android and doesnt have any effect on your UI. That is what I meant.

vijai2011 said:
I meant in android phone. Not your eclipse logcat console. All System.out.print are directed to logcat in android and doesnt have any effect on your UI. That is what I meant.
Click to expand...
Click to collapse
Here is my logcat
09-13 05:28:34.219: D/All 1288): {"success":1,"question":[{"question":"Question2"}]}
09-13 05:28:34.219: D/users_list.length() 1288): 1
09-13 05:28:34.839: W/System.err(1288): org.json.JSONException: No value for question0
09-13 05:28:34.879: W/System.err(1288): at org.json.JSONObject.get(JSONObject.java:354)
09-13 05:28:35.231: W/System.err(1288): at org.json.JSONObject.getString(JSONObject.java:510)
09-13 05:28:35.289: W/System.err(1288): at com.example.newairways.day1q1$Question.doInBackground(day1q1.java:474)
09-13 05:28:35.309: W/System.err(1288): at com.example.newairways.day1q1$Question.doInBackground(day1q1.java:1)
09-13 05:28:35.309: W/System.err(1288): at android.os.AsyncTask$2.call(AsyncTask.java:264)
09-13 05:28:35.309: W/System.err(1288): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
09-13 05:28:35.309: W/System.err(1288): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
09-13 05:28:35.381: W/System.err(1288): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
09-13 05:28:35.381: W/System.err(1288): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
09-13 05:28:35.381: W/System.err(1288): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
09-13 05:28:35.389: W/System.err(1288): at java.lang.Thread.run(Thread.java:856)
09-13 05:28:35.469: I/System.out(1288): usersMap.get(User1) : null

raja_king said:
Here is my logcat
09-13 05:28:34.219: D/All 1288): {"success":1,"question":[{"question":"Question2"}]}
09-13 05:28:34.219: D/users_list.length() 1288): 1
09-13 05:28:34.839: W/System.err(1288): org.json.JSONException: No value for question0
09-13 05:28:34.879: W/System.err(1288): at org.json.JSONObject.get(JSONObject.java:354)
09-13 05:28:35.231: W/System.err(1288): at org.json.JSONObject.getString(JSONObject.java:510)
09-13 05:28:35.289: W/System.err(1288): at com.example.newairways.day1q1$Question.doInBackground(day1q1.java:474)
09-13 05:28:35.309: W/System.err(1288): at com.example.newairways.day1q1$Question.doInBackground(day1q1.java:1)
09-13 05:28:35.309: W/System.err(1288): at android.os.AsyncTask$2.call(AsyncTask.java:264)
09-13 05:28:35.309: W/System.err(1288): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
09-13 05:28:35.309: W/System.err(1288): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
09-13 05:28:35.381: W/System.err(1288): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
09-13 05:28:35.381: W/System.err(1288): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
09-13 05:28:35.381: W/System.err(1288): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
09-13 05:28:35.389: W/System.err(1288): at java.lang.Thread.run(Thread.java:856)
09-13 05:28:35.469: I/System.out(1288): usersMap.get(User1) : null
Click to expand...
Click to collapse
The logcat says there is no value for question0 which means that the php on your remote server doesnt return json correctly.
you can add the below code to your php script and check if the json array is displayed correctly on your browser.
Code:
echo json_encode($your_json_array);

Sloved
vijai2011 said:
The logcat says there is no value for question0 which means that the php on your remote server doesnt return json correctly.
you can add the below code to your php script and check if the json array is displayed correctly on your browser.
Code:
echo json_encode($your_json_array);
Click to expand...
Click to collapse
Hi I sloved my problem. Thank you so much for your time. Lets keep in touch.And Nice to meet you.

Related

[Q] Android RSS FEED Reader issues

I want to developer RSS FEED reader for android. I am following this tutorial : http://www.ibm.com/developerworks/xml/tutorials/x-androidrss/downloads.html
I am not getting any error in the program but not getting desired output
**This is my logcat:**
Code:
07-20 16:12:23.531: ERROR/Zygote(33): setreuid() failed. errno: 2
07-20 16:12:35.101: ERROR/Zygote(33): setreuid() failed. errno: 17
07-20 16:12:37.031: ERROR/BatteryService(59): usbOnlinePath not found
07-20 16:12:37.031: ERROR/BatteryService(59): batteryVoltagePath not found
07-20 16:12:37.031: ERROR/BatteryService(59): batteryTemperaturePath not found
07-20 16:12:37.061: ERROR/SurfaceFlinger(59): Couldn't open /sys/power/wait_for_fb_sleep or /sys/power/wait_for_fb_wake
07-20 16:12:47.381: ERROR/EventHub(59): could not get driver version for /dev/input/mouse0, Not a typewriter
07-20 16:12:47.412: ERROR/EventHub(59): could not get driver version for /dev/input/mice, Not a typewriter
07-20 16:12:47.812: ERROR/System(59): Failure starting core service
07-20 16:12:47.812: ERROR/System(59): java.lang.SecurityException
07-20 16:12:47.812: ERROR/System(59): at android.os.BinderProxy.transact(Native Method)
07-20 16:12:47.812: ERROR/System(59): at android.os.ServiceManagerProxy.addService(ServiceManagerNative.java:146)
07-20 16:12:47.812: ERROR/System(59): at android.os.ServiceManager.addService(ServiceManager.java:72)
07-20 16:12:47.812: ERROR/System(59): at com.android.server.ServerThread.run(SystemServer.java:184)
07-20 16:12:49.591: ERROR/SoundPool(59): error loading /system/media/audio/ui/Effect_Tick.ogg
07-20 16:12:49.591: ERROR/SoundPool(59): error loading /system/media/audio/ui/KeypressStandard.ogg
07-20 16:12:49.602: ERROR/SoundPool(59): error loading /system/media/audio/ui/KeypressSpacebar.ogg
07-20 16:12:49.612: ERROR/SoundPool(59): error loading /system/media/audio/ui/KeypressDelete.ogg
07-20 16:12:49.622: ERROR/SoundPool(59): error loading /system/media/audio/ui/KeypressReturn.ogg
07-20 16:12:52.672: ERROR/ThrottleService(59): Could not open GPS configuration file /etc/gps.conf
07-20 16:12:54.551: ERROR/logwrapper(145): executing /system/bin/tc failed: No such file or directory
07-20 16:12:54.691: ERROR/logwrapper(147): executing /system/bin/tc failed: No such file or directory
07-20 16:12:54.781: ERROR/logwrapper(149): executing /system/bin/tc failed: No such file or directory
07-20 16:13:17.789: ERROR/HierarchicalStateMachine(59): TetherMaster - unhandledMessage: msg.what=3
07-20 16:13:38.669: INFO/ActivityManager(59): Start proc com.svox.pico for broadcast com.svox.pico/.VoiceDataInstallerReceiver: pid=268 uid=10028 gids={}
07-20 16:13:38.689: WARN/RecognitionManagerService(59): no available voice recognition services found
07-20 16:13:39.370: DEBUG/dalvikvm(59): GC_EXPLICIT freed 9347 objects / 593752 bytes in 302ms
07-20 16:13:39.590: DEBUG/dalvikvm(165): GC_EXPLICIT freed 2883 objects / 156272 bytes in 1275ms
07-20 16:13:39.659: INFO/installd(35): unlink /data/dalvik-cache/[email protected]@[email protected]
07-20 16:13:39.782: DEBUG/AndroidRuntime(118): Shutting down VM
07-20 16:13:39.789: DEBUG/jdwp(118): adbd disconnected
07-20 16:13:39.809: INFO/AndroidRuntime(118): NOTE: attach of thread 'Binder Thread #3' failed
07-20 16:13:39.879: INFO/ActivityThread(268): Publishing provider com.svox.pico.providers.SettingsProvider: com.svox.pico.providers.SettingsProvider
07-20 16:13:40.131: DEBUG/KeyguardViewMediator(59): pokeWakelock(5000)
07-20 16:13:40.429: DEBUG/KeyguardViewMediator(59): pokeWakelock(5000)
07-20 16:13:40.511: DEBUG/AndroidRuntime(278): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
07-20 16:13:40.511: DEBUG/AndroidRuntime(278): CheckJNI is ON
07-20 16:13:41.740: INFO/ActivityManager(59): Displayed activity com.android.launcher/com.android.launcher2.Launcher: 50234 ms (total 50234 ms)
07-20 16:13:42.340: DEBUG/AndroidRuntime(278): --- registering native functions ---
07-20 16:13:43.790: INFO/ActivityManager(59): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.msi.androidrss/.ShowDescription }
07-20 16:13:43.890: DEBUG/AndroidRuntime(278): Shutting down VM
07-20 16:13:43.910: DEBUG/jdwp(278): adbd disconnected
07-20 16:13:43.960: INFO/AndroidRuntime(278): NOTE: attach of thread 'Binder Thread #3' failed
07-20 16:13:44.099: INFO/ActivityManager(59): Start proc com.msi.androidrss for activity com.msi.androidrss/.ShowDescription: pid=286 uid=10042 gids={1015}
07-20 16:13:45.939: INFO/ARMAssembler(59): generated scanline__00000077:03545404_00000004_00000000 [ 47 ipp] (67 ins) at [0x2ff7e0:0x2ff8ec] in 7962326 ns
07-20 16:13:46.670: INFO/ActivityManager(59): Displayed activity com.msi.androidrss/.ShowDescription: 2691 ms (total 2691 ms)
**This is my manifest.xml**
Code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.msi.androidrss"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".RSSReader"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
</intent-filter>
</activity>
</application>
</manifest>
**This is one of my .java program "RSSReader.java"**
Code:
package com.msi.androidrss;
import android.app.Activity;
import android.os.Bundle;
import android.view.*;
import android.widget.TextView;
import android.widget.ListView;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.AdapterView.OnItemClickListener;
import android.util.Log;
import java.net.URL;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
import android.content.Intent;
import com.msi.androidrss.ShowDescription;
public class RSSReader extends Activity implements OnItemClickListener
{
public final String RSSFEEDOFCHOICE = "http://www.ibm.com/developerworks/views/rss/customrssatom.jsp?zone_by=XML&zone_by=Java&zone_by=Rational&zone_by=Linux&zone_by=Open+source&zone_by=WebSphere&type_by=Tutorials&search_by=&day=1&month=06&year=2007&max_entries=20&feed_by=rss&isGUI=true&Submit.x=48&Submit.y=14";
private static final int SELECT = 0;
private static final int REFRESH = 1;
public final String tag = "RSSReader";
private RSSFeed feed = null;
/** Called when the activity is first created. */
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
// go get our feed!
feed = getFeed(RSSFEEDOFCHOICE);
// display UI
UpdateDisplay();
}
private RSSFeed getFeed(String urlToRssFeed)
{
try
{
// setup the url
URL url = new URL(urlToRssFeed);
// create the factory
SAXParserFactory factory = SAXParserFactory.newInstance();
// create a parser
SAXParser parser = factory.newSAXParser();
// create the reader (scanner)
XMLReader xmlreader = parser.getXMLReader();
// instantiate our handler
RSSHandler theRssHandler = new RSSHandler();
// assign our handler
xmlreader.setContentHandler(theRssHandler);
// get our data via the url class
InputSource is = new InputSource(url.openStream());
// perform the synchronous parse
xmlreader.parse(is);
// get the results - should be a fully populated RSSFeed instance, or null on error
return theRssHandler.getFeed();
}
catch (Exception ee)
{
// if we have a problem, simply return null
return null;
}
}
public boolean onCreateOptionsMenu(Menu menu)
{
super.onCreateOptionsMenu(menu);
menu.add(0, RSSReader.SELECT, 0, "Choose RSS Feed").setIcon(android.R.drawable.ic_menu_mapmode);
//menu.add(0,0,"Choose RSS Feed");
//menu.add(0,1,"Refresh");
menu.add(0, RSSReader.REFRESH, 0, "Refresh").setIcon(android.R.drawable.ic_menu_mapmode);
Log.i(tag,"onCreateOptionsMenu");
return true;
}
@Override
public boolean onMenuItemSelected(final int featureId, final MenuItem item) {
switch (item.getItemId()) {
case RSSReader.SELECT:
Log.i(tag,"Set RSS Feed");
return true;
case RSSReader.REFRESH:
Log.i(tag,"Refreshing RSS Feed");
return true;
}
return false;
}
private void UpdateDisplay()
{
TextView feedtitle = (TextView) findViewById(R.id.feedtitle);
TextView feedpubdate = (TextView) findViewById(R.id.feedpubdate);
ListView itemlist = (ListView) findViewById(R.id.itemlist);
if (feed == null)
{
feedtitle.setText("No RSS Feed Available");
return;
}
feedtitle.setText(feed.getTitle());
feedpubdate.setText(feed.getPubDate());
ArrayAdapter<RSSItem> adapter = new ArrayAdapter<RSSItem>(this,android.R.layout.simple_list_item_1,feed.getAllItems());
itemlist.setAdapter(adapter);
itemlist.setOnItemClickListener(this);
itemlist.setSelection(0);
}
public void onItemClick(AdapterView<?> parent, View v, int position, long id)
{
Log.i(tag,"item clicked! [" + feed.getItem(position).getTitle() + "]");
Intent itemintent = new Intent(this,ShowDescription.class);
Bundle b = new Bundle();
b.putString("title", feed.getItem(position).getTitle());
b.putString("description", feed.getItem(position).getDescription());
b.putString("link", feed.getItem(position).getLink());
b.putString("pubdate", feed.getItem(position).getPubDate());
itemintent.putExtra("android.intent.extra.INTENT", b);
startActivity(itemintent);
}
}
**This is one of my .java program "ShowDescription.java"**
Code:
package com.msi.androidrss;
import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;
import android.content.Intent;
import android.view.*;
public class ShowDescription extends Activity
{
public void onCreate(Bundle icicle)
{
super.onCreate(icicle);
setContentView(R.layout.showdescription);
String theStory = null;
Intent startingIntent = getIntent();
if (startingIntent != null)
{
Bundle b = startingIntent.getBundleExtra("android.intent.extra.INTENT");
if (b == null)
{
theStory = "bad bundle?";
}
else
{
theStory = b.getString("title") + "\n\n" + b.getString("pubdate") + "\n\n" + b.getString("description").replace('\n',' ') + "\n\nMore information:\n" + b.getString("link");
}
}
else
{
theStory = "Information Not Found.";
}
TextView db= (TextView) findViewById(R.id.storybox);
db.setText(theStory);
Button backbutton = (Button) findViewById(R.id.back);
backbutton.setOnClickListener(new Button.OnClickListener()
{
public void onClick(View v)
{
finish();
}
});
}
}
**As an output I am getting "*"NO RSS FEED AVAILABLE"*", why ?**
**HELP!!!**
I found the IBM tutorial very hard to follow, I eventually read RSS through a simpler way. Here is a link to the tutorial I wrote after:
http://droidapp.co.uk/?p=166
eatmold said:
I found the IBM tutorial very hard to follow, I eventually read RSS through a simpler way. Here is a link to the tutorial I wrote after:
http://droidapp.co.uk/?p=166
Click to expand...
Click to collapse
Thanks, could you plz upload the full source code ?
Does it support images and clickable feed so that clicking any feed directs the user to the website ?
I will upload the full source of my app today.
It will read any section of the xml so if there are images you will be able to extract the URL and use it in your app. It does support clickable feed also, just by extracting the post URL again.
The app I made is for an audio podcast.
Here you go... hope it helps
http://dl.dropbox.com/u/6876950/EppyGibbonPodcast.zip
help
hello tony,
first thank you for the source code.
I tried running your source code but I am getting these error messages:
Code:
Description Resource Path Location Type
Project 'EppyGibbonPodcast' is missing required library: 'C:\Users\Tony.DZNT\AndroidDev\android-sdk-windows\extras\android\compatibility\v4\android-support-v4.jar' EppyGibbonPodcast Build path Build Path Problem
The project cannot be built until build path errors are resolved EppyGibbonPodcast Unknown Java Problem
Attribute minSdkVersion (4) is lower than the project target API level (10) AndroidManifest.xml /EppyGibbonPodcast line 1 Android ADT Problem
This is the version of my eclipse:
Code:
Eclipse IDE for Java Developers
Version: Helios Service Release 2
Build id: 20110218-0911
I am using 2.2 but I can see you created this code for 2.3. I do have API installed for 3.0 and 3.1 etc so I should be at-least able to run the program on virtual mobile (on PC thru eclipse) but getting the above error msgs.
Please Help.
I just found the file "android-support-v4.jar" in this location:
D:\Android\AndroidSDK\android-sdk-windows\extras\android\compatibility\v4
now how and where I can link this path ?
eatmold said:
I found the IBM tutorial very hard to follow, I eventually read RSS through a simpler way. Here is a link to the tutorial I wrote after:
http://droidapp.co.uk/?p=166
Click to expand...
Click to collapse
very clean and precise. i really like well compartmentalized code
iamsuper123 said:
I just found the file "android-support-v4.jar" in this location:
D:\Android\AndroidSDK\android-sdk-windows\extras\android\compatibility\v4
now how and where I can link this path ?
Click to expand...
Click to collapse
Sorry, I must have left that in from when I was playing with Fragments, it's not needed. You can remove it from the build path. Right click the project, properties, then find and remove from build path.
Hi tony,
I did try to remove it and now I am getting these errors:
Code:
Description Resource Path Location Type
FragmentActivity cannot be resolved to a type podcast.java /EppyGibbonPodcast/src/com/owentech/eppygibbonpodcast line 14 Java Problem
FragmentActivity cannot be resolved to a type podcast.java /EppyGibbonPodcast/src/com/owentech/eppygibbonpodcast line 19 Java Problem
The import android.support cannot be resolved podcast.java /EppyGibbonPodcast/src/com/owentech/eppygibbonpodcast line 8 Java Problem
The method findViewById(int) is undefined for the type podcast podcast.java /EppyGibbonPodcast/src/com/owentech/eppygibbonpodcast line 24 Java Problem
The method findViewById(int) is undefined for the type podcast podcast.java /EppyGibbonPodcast/src/com/owentech/eppygibbonpodcast line 27 Java Problem
The method findViewById(int) is undefined for the type podcast podcast.java /EppyGibbonPodcast/src/com/owentech/eppygibbonpodcast line 30 Java Problem
The method getIntent() is undefined for the type podcast podcast.java /EppyGibbonPodcast/src/com/owentech/eppygibbonpodcast line 32 Java Problem
The method onCreate(Bundle) of type podcast must override a superclass method podcast.java /EppyGibbonPodcast/src/com/owentech/eppygibbonpodcast line 17 Java Problem
The method setContentView(int) is undefined for the type podcast podcast.java /EppyGibbonPodcast/src/com/owentech/eppygibbonpodcast line 21 Java Problem
The method startActivity(Intent) is undefined for the type new View.OnClickListener(){} podcast.java /EppyGibbonPodcast/src/com/owentech/eppygibbonpodcast line 57 Java Problem
The method startActivity(Intent) is undefined for the type new View.OnClickListener(){} podcast.java /EppyGibbonPodcast/src/com/owentech/eppygibbonpodcast line 67 Java Problem
AdapterView is a raw type. References to generic type AdapterView<T> should be parameterized main.java /EppyGibbonPodcast/src/com/owentech/eppygibbonpodcast line 50 Java Problem
Attribute minSdkVersion (4) is lower than the project target API level (10) AndroidManifest.xml /EppyGibbonPodcast line 1 Android ADT Problem
The import com.owentech.eppygibbonpodcast.R is never used arrays.java /EppyGibbonPodcast/src/com/owentech/eppygibbonpodcast line 3 Java Problem
I would deeply appreciate if you could upload a fresh copy of source code without this fragment file / issue.
thank you
OK. I'll upload again tomorrow.
thanks i will keep an eye on your site and here
I have re-uploaded the source, now without the Fragment compatability.
http://dl.dropbox.com/u/6876950/EppyGibbonPodcast.zip
Let me know if you have any problems, but this should run fine now.
Tony
thank you very much tony
it does work now.
I just get these warnings:
Code:
Description Resource Path Location Type
AdapterView is a raw type. References to generic type AdapterView<T> should be parameterized main.java /EppyGibbonPodcast/src/com/owentech/eppygibbonpodcast line 50 Java Problem
AdapterView is a raw type. References to generic type AdapterView<T> should be parameterized rsstest.java /rsstest/src/com/owentech/eppygibbonpodcast line 50 Java Problem
Attribute minSdkVersion (4) is lower than the project target API level (10) AndroidManifest.xml /EppyGibbonPodcast line 1 Android ADT Problem
I tested the code and I think it only works for the RSS FEED that you added in the code.
I tried other rss feed like "http://rss.news.yahoo.com/rss/mostviewed" mentioned on your website (in comments) and few other rss feeds but nothing seems to be working.
(thanks once for all the help)
I wouldn't worry about those warnings.
The app I have uploaded is specifically for the Epileptic Gibbon Podcast, which is a wordpress site.
The code should just need slight changes to match the rss feed you want to use. I suggest you download the rss xml for Epileptic Gibbon and the rss xml for Yahoo and compare the differences.
really great code.
Thanks.
I could really use some help.
I would like to use this app to pull feeds for this site.
http://las-vegas-drunk-driving-attorney.com/
But have no idea how to add this to eclipse and then turn it in to an app.
Could someone help out with the steps to take?
Thank.

[Q] What is wrong with my project?

Hi all, I'm fairly new to Java and my overall coding skills are not as advanced as I'd like them to be but I really would appreciate it if someone could help me with this problem.
My first goal is to code an application for Android which measures the acceleration (X, Y, Z directions) and displays the values in a TextView.
There will be other user configurable options like unit conversion or limits with audio warnings etc. later on.
Right now I only have a few lines of code and the application already force closes right after starting.
I am posting my MainActivity.java, my activity_main.xml and the sensoractivity2 Manifest. Please point me in the right direction!
MainActivity.java:
Code:
package com.example.sensoractivity2;
import android.app.Activity;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.widget.TextView;
public class MainActivity extends Activity implements SensorEventListener{
private SensorManager sensorManager;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
sensorManager=(SensorManager) getSystemService(SENSOR_SERVICE);
sensorManager.registerListener(this, sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_NORMAL);
}
public void onSensorChanged(SensorEvent event) {
float x, y, z = 0;
if (event.sensor.getType()==Sensor.TYPE_ACCELEROMETER) {
x=event.values[0];
y=event.values[1];
z=event.values[2];
TextView tx = (TextView) findViewById(R.id.textView1);
tx.setText((int) x);
TextView ty = (TextView) findViewById(R.id.textView2);
ty.setText((int) y);
TextView tz = (TextView) findViewById(R.id.textView3);
tz.setText((int) z);
}
}
[user=439709]@override[/user]
public void onAccuracyChanged(Sensor arg0, int arg1) {
// TODO Auto-generated method stub
}
}
activity_main.xml
Code:
<?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="match_parent"
android:layout_height="match_parent"
android:text="X-Wert" />
<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Y-Wert" />
<TextView
android:id="@+id/textView3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Z-Wert" />
</LinearLayout>
sensoractivity2 Manifest:
Code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.sensoractivity2"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk
android:minSdkVersion="8"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity android:name="com.example.sensoractivity2.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
First thing I see is that you are not setting your view in your activity classes "oncreate" method. Can you post your logcat output when the app force closes? That will help the most.
Could you please post a logcat?
Just the lines of your app. Get it using the logcat view in Eclipse.
Look at the bold for changes that will help you. When you are working with view objects, you shouldn't create the object in a listener or something that is called over and over. You will be creating a memory leak.
Code:
package com.example.sensoractivity2;
import android.app.Activity;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.widget.TextView;
public class MainActivity extends Activity implements SensorEventListener{
private SensorManager sensorManager;
[B]TextView tx = null;
TextView ty = null;
TextView tz = null;[/B]
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
sensorManager=(SensorManager) getSystemService(SENSOR_SERVICE);
[B] setContentView(R.layout.activity_main);[/B]
sensorManager.registerListener(this, sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_NORMAL);
[B]tx = (TextView) findViewById(R.id.textView1);
ty = (TextView) findViewById(R.id.textView2);
tz = (TextView) findViewById(R.id.textView3);[/B]
}
public void onSensorChanged(SensorEvent event) {
float x, y, z = 0;
if (event.sensor.getType()==Sensor.TYPE_ACCELEROMETER) {
x=event.values[0];
y=event.values[1];
z=event.values[2];
[B]tx.setText((int) x);
ty.setText((int) y);
tz.setText((int) z);[/B]
}
}
[user=439709]@override[/user]
public void onAccuracyChanged(Sensor arg0, int arg1) {
// TODO Auto-generated method stub
}
}
Here is the part of the catlog which I believe to be relevant when the crash occurs:
Code:
04-28 18:34:24.628: E/SurfaceFlinger(36): ro.sf.lcd_density must be defined as a build property
04-28 18:34:25.750: E/Trace(1735): error opening trace file: No such file or directory (2)
04-28 18:34:27.452: I/ARMAssembler(36): generated scanline__00000077:03515104_00009002_00000000 [127 ipp] (149 ins) at [0x40f081f0:0x40f08444] in 34521256 ns
04-28 18:34:29.430: I/Choreographer(1153): Skipped 388 frames! The application may be doing too much work on its main thread.
04-28 18:34:29.462: I/ARMAssembler(36): generated scanline__00000077:03010104_00008002_00000000 [ 89 ipp] (110 ins) at [0x40f08450:0x40f08608] in 17654283 ns
04-28 18:34:30.825: W/ActivityManager(1003): Launch timeout has expired, giving up wake lock!
04-28 18:34:31.673: D/AndroidRuntime(1735): Shutting down VM
04-28 18:34:31.673: W/dalvikvm(1735): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
04-28 18:34:31.737: E/AndroidRuntime(1735): FATAL EXCEPTION: main
04-28 18:34:31.737: E/AndroidRuntime(1735): java.lang.NullPointerException
04-28 18:34:31.737: E/AndroidRuntime(1735): at com.example.sensoractivity2.MainActivity.onSensorChanged(MainActivity.java:27)
04-28 18:34:31.737: E/AndroidRuntime(1735): at android.hardware.SystemSensorManager$ListenerDelegate$1.handleMessage(SystemSensorManager.java:204)
04-28 18:34:31.737: E/AndroidRuntime(1735): at android.os.Handler.dispatchMessage(Handler.java:99)
04-28 18:34:31.737: E/AndroidRuntime(1735): at android.os.Looper.loop(Looper.java:137)
04-28 18:34:31.737: E/AndroidRuntime(1735): at android.app.ActivityThread.main(ActivityThread.java:5041)
04-28 18:34:31.737: E/AndroidRuntime(1735): at java.lang.reflect.Method.invokeNative(Native Method)
04-28 18:34:31.737: E/AndroidRuntime(1735): at java.lang.reflect.Method.invoke(Method.java:511)
04-28 18:34:31.737: E/AndroidRuntime(1735): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
04-28 18:34:31.737: E/AndroidRuntime(1735): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
04-28 18:34:31.737: E/AndroidRuntime(1735): at dalvik.system.NativeStart.main(Native Method)
04-28 18:34:31.813: W/ActivityManager(1003): Force finishing activity com.example.sensoractivity2/.MainActivity
04-28 18:34:31.893: W/WindowManager(1003): Failure taking screenshot for (328x583) to layer 21010
04-28 18:34:32.643: D/dalvikvm(1003): GC_FOR_ALLOC freed 588K, 26% free 7082K/9496K, paused 471ms, total 481ms
Thanks for your hints, zalez! Going to try that now.
The logcat states a nullpointer error. I believe my corrections will fix at least that error.
spelaben said:
Here is the part of the catlog which I believe to be relevant when the crash occurs:
Code:
04-28 18:34:24.628: E/SurfaceFlinger(36): ro.sf.lcd_density must be defined as a build property
04-28 18:34:25.750: E/Trace(1735): error opening trace file: No such file or directory (2)
04-28 18:34:27.452: I/ARMAssembler(36): generated scanline__00000077:03515104_00009002_00000000 [127 ipp] (149 ins) at [0x40f081f0:0x40f08444] in 34521256 ns
04-28 18:34:29.430: I/Choreographer(1153): Skipped 388 frames! The application may be doing too much work on its main thread.
04-28 18:34:29.462: I/ARMAssembler(36): generated scanline__00000077:03010104_00008002_00000000 [ 89 ipp] (110 ins) at [0x40f08450:0x40f08608] in 17654283 ns
04-28 18:34:30.825: W/ActivityManager(1003): Launch timeout has expired, giving up wake lock!
04-28 18:34:31.673: D/AndroidRuntime(1735): Shutting down VM
04-28 18:34:31.673: W/dalvikvm(1735): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
04-28 18:34:31.737: E/AndroidRuntime(1735): FATAL EXCEPTION: main
04-28 18:34:31.737: E/AndroidRuntime(1735): java.lang.NullPointerException
04-28 18:34:31.737: E/AndroidRuntime(1735): at com.example.sensoractivity2.MainActivity.onSensorChanged(MainActivity.java:27)
04-28 18:34:31.737: E/AndroidRuntime(1735): at android.hardware.SystemSensorManager$ListenerDelegate$1.handleMessage(SystemSensorManager.java:204)
04-28 18:34:31.737: E/AndroidRuntime(1735): at android.os.Handler.dispatchMessage(Handler.java:99)
04-28 18:34:31.737: E/AndroidRuntime(1735): at android.os.Looper.loop(Looper.java:137)
04-28 18:34:31.737: E/AndroidRuntime(1735): at android.app.ActivityThread.main(ActivityThread.java:5041)
04-28 18:34:31.737: E/AndroidRuntime(1735): at java.lang.reflect.Method.invokeNative(Native Method)
04-28 18:34:31.737: E/AndroidRuntime(1735): at java.lang.reflect.Method.invoke(Method.java:511)
04-28 18:34:31.737: E/AndroidRuntime(1735): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
04-28 18:34:31.737: E/AndroidRuntime(1735): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
04-28 18:34:31.737: E/AndroidRuntime(1735): at dalvik.system.NativeStart.main(Native Method)
04-28 18:34:31.813: W/ActivityManager(1003): Force finishing activity com.example.sensoractivity2/.MainActivity
04-28 18:34:31.893: W/WindowManager(1003): Failure taking screenshot for (328x583) to layer 21010
04-28 18:34:32.643: D/dalvikvm(1003): GC_FOR_ALLOC freed 588K, 26% free 7082K/9496K, paused 471ms, total 481ms
Thanks for your hints, zalez! Going to try that now.
Click to expand...
Click to collapse
zalez said:
The logcat states a nullpointer error. I believe my corrections will fix at least that error.
Click to expand...
Click to collapse
True, nullpointer errors are fixed. After debugging it again, I'm getting these errors now:
Code:
04-28 19:07:59.466: E/AndroidRuntime(858): FATAL EXCEPTION: main
04-28 19:07:59.466: E/AndroidRuntime(858): android.content.res.Resources$NotFoundException: String resource ID #0x0
04-28 19:07:59.466: E/AndroidRuntime(858): at android.content.res.Resources.getText(Resources.java:230)
04-28 19:07:59.466: E/AndroidRuntime(858): at android.widget.TextView.setText(TextView.java:3769)
04-28 19:07:59.466: E/AndroidRuntime(858): at com.example.sensoractivity2.MainActivity.onSensorChanged(MainActivity.java:33)
04-28 19:07:59.466: E/AndroidRuntime(858): at android.hardware.SystemSensorManager$ListenerDelegate$1.handleMessage(SystemSensorManager.java:204)
04-28 19:07:59.466: E/AndroidRuntime(858): at android.os.Handler.dispatchMessage(Handler.java:99)
04-28 19:07:59.466: E/AndroidRuntime(858): at android.os.Looper.loop(Looper.java:137)
04-28 19:07:59.466: E/AndroidRuntime(858): at android.app.ActivityThread.main(ActivityThread.java:5041)
04-28 19:07:59.466: E/AndroidRuntime(858): at java.lang.reflect.Method.invokeNative(Native Method)
04-28 19:07:59.466: E/AndroidRuntime(858): at java.lang.reflect.Method.invoke(Method.java:511)
04-28 19:07:59.466: E/AndroidRuntime(858): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
04-28 19:07:59.466: E/AndroidRuntime(858): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
04-28 19:07:59.466: E/AndroidRuntime(858): at dalvik.system.NativeStart.main(Native Method)
Any ideas?
spelaben said:
True, nullpointer errors are fixed. After debugging it again, I'm getting these errors now:
Code:
04-28 19:07:59.466: E/AndroidRuntime(858): FATAL EXCEPTION: main
04-28 19:07:59.466: E/AndroidRuntime(858): android.content.res.Resources$NotFoundException: String resource ID #0x0
04-28 19:07:59.466: E/AndroidRuntime(858): at android.content.res.Resources.getText(Resources.java:230)
04-28 19:07:59.466: E/AndroidRuntime(858): at android.widget.TextView.setText(TextView.java:3769)
04-28 19:07:59.466: E/AndroidRuntime(858): at com.example.sensoractivity2.MainActivity.onSensorChanged(MainActivity.java:33)
04-28 19:07:59.466: E/AndroidRuntime(858): at android.hardware.SystemSensorManager$ListenerDelegate$1.handleMessage(SystemSensorManager.java:204)
04-28 19:07:59.466: E/AndroidRuntime(858): at android.os.Handler.dispatchMessage(Handler.java:99)
04-28 19:07:59.466: E/AndroidRuntime(858): at android.os.Looper.loop(Looper.java:137)
04-28 19:07:59.466: E/AndroidRuntime(858): at android.app.ActivityThread.main(ActivityThread.java:5041)
04-28 19:07:59.466: E/AndroidRuntime(858): at java.lang.reflect.Method.invokeNative(Native Method)
04-28 19:07:59.466: E/AndroidRuntime(858): at java.lang.reflect.Method.invoke(Method.java:511)
04-28 19:07:59.466: E/AndroidRuntime(858): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
04-28 19:07:59.466: E/AndroidRuntime(858): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
04-28 19:07:59.466: E/AndroidRuntime(858): at dalvik.system.NativeStart.main(Native Method)
Any ideas?
Click to expand...
Click to collapse
It needs to be
Code:
tx.setText(String.valueOf(x));
ty.setText(String.valueOf(y));
tz.setText(String.valueOf(z));
If you pass an int, the TextView thinks that it is a resource id. That is why you need to convert it to a String first.
I over looked the bold part. When setting text for a Textview, it has to be in string format. There is no implied conversion.
Code:
package com.example.sensoractivity2;
import android.app.Activity;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.widget.TextView;
public class MainActivity extends Activity implements SensorEventListener{
private SensorManager sensorManager;
TextView tx = null;
TextView ty = null;
TextView tz = null;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
sensorManager=(SensorManager) getSystemService(SENSOR_SERVICE);
setContentView(R.layout.activity_main);
sensorManager.registerListener(this, sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_NORMAL);
tx = (TextView) findViewById(R.id.textView1);
ty = (TextView) findViewById(R.id.textView2);
tz = (TextView) findViewById(R.id.textView3);
}
public void onSensorChanged(SensorEvent event) {
float x, y, z = 0;
if (event.sensor.getType()==Sensor.TYPE_ACCELEROMETER) {
x=event.values[0];
y=event.values[1];
z=event.values[2];
tx.setText[B](Integer.toString(x)[/B]);
ty.setText([B]Integer.toString(y)[/B]);
tz.setText([B]Integer.toString(z)[/B]);
}
}
[user=439709]@override[/user]
public void onAccuracyChanged(Sensor arg0, int arg1) {
// TODO Auto-generated method stub
}
}
nikwen said:
It needs to be
Code:
tx.setText(String.valueOf(x));
ty.setText(String.valueOf(y));
tz.setText(String.valueOf(z));
If you pass an int, the TextView thinks that it is a resource id. That is why you need to convert it to a String first.
Click to expand...
Click to collapse
Yes! That did the trick! Now my next problem is that I only see one value instead of three, from there on I will try to move on by myself.
Sorry, I'm not sure if this is relevant, but you aren't overriding your onCreate method? Could that have anything to do with it?
MaartenXDA said:
Sorry, I'm not sure if this is relevant, but you aren't overriding your onCreate method? Could that have anything to do with it?
Click to expand...
Click to collapse
He does:
public void onCreate(Bundle savedInstanceState) {
Click to expand...
Click to collapse
He just did not wrote the @override annotation before that. As far as i know, you do not have to use it.
EDIT: Yep, it does not matter. See this: http://stackoverflow.com/questions/94361/when-do-you-use-javas-override-annotation-and-why
It says that it is just for ensuring that you are overriding the right method and for making the code easier to read.
Hi all, I am a bit further with my project since I found some time to work on it again.
//edit, force closes on starting fixed!
Here is what it is supposed to be doing: It reads the x, y and z values for acceleration from the LINEAR_ACCELERATION sensor. If a certain value is exceeded a timer will be started. If the amount of seconds the timer counts is higher than a defined threshold, it will play the default notifcation sound.
If the value from the sensor is below the threshold, it will stop the timer. The whole timer thing isn't working, the notification is played as soon as the normal acceleration threshold is passed and the time is ignored.
Please review my code below and tell me what I'm not seeing here, note that I'm still a noob.
Also I'm interested in a method to capture the maximum values read from the sensor and put it in a textview, can you help me?
AccelMeter.java:
Code:
package com.example.accelmeter;
import android.app.Activity;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.media.Ringtone;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Bundle;
import android.os.SystemClock;
import android.view.View;
import android.widget.Button;
import android.widget.Chronometer;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
public class AccelMeter extends Activity implements SensorEventListener {
private SensorManager sensorManager;
// Objekte deklarieren
TextView xC;
TextView yC;
TextView zC;
Chronometer chrono;
/* accThreshold = Schwellenwert in m/s² für die Beschleunigung
* accInterval = Zeitraum in Sekunden, über den der Wert für die Beschleunigung überwacht wird
*/
private float accThreshold = 50;
private float accInterval = 0;
[user=439709]@override[/user]
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_accel_meter);
// Achsen Objekte erstellen
xC=(TextView)findViewById(R.id.xCoordinate);
yC=(TextView)findViewById(R.id.yCoordinate);
zC=(TextView)findViewById(R.id.zCoordinate);
/* Sensor.TYPE_LINEAR_ACCELERATION = Beschleunigung auf jeder Achse ohne Gravitation in m/s²
* SENSOR_DELAY_FASTEST = schnellster Modus für Messung. Alternativen z.B. _GAME, _NORMAL oder _UI
*/
sensorManager=(SensorManager)getSystemService(SENSOR_SERVICE);
sensorManager.registerListener(this,
sensorManager.getDefaultSensor(Sensor.TYPE_LINEAR_ACCELERATION),
SensorManager.SENSOR_DELAY_NORMAL);
// Schwellenwert festlegen und mit einer Toast-Benachrichtigung bestätigen, Fehlerbehandlung wenn kein Wert eingegeben wurde
Button setThreshold = (Button)findViewById(R.id.setThreshold);
setThreshold.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
try {
EditText et = (EditText)findViewById(R.id.threshold);
accThreshold = Float.valueOf(et.getText().toString());
Toast.makeText(getApplicationContext(), "Neuer Schwellenwert festgelegt!", Toast.LENGTH_SHORT).show();
}
catch (Exception e) {
Toast.makeText(getApplicationContext(), "Es wurde noch kein Wert eingegeben!", Toast.LENGTH_SHORT).show();
}
}
});
// Intervall festlegen und mit einer Toast-Benachrichtigung bestätigen, Fehlerbehandlung wenn kein Wert eingegeben wurde
Button setInterval = (Button)findViewById(R.id.setInterval);
setInterval.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
try {
EditText et = (EditText)findViewById(R.id.editInterval);
accInterval = Float.valueOf(et.getText().toString());
Toast.makeText(getApplicationContext(), "Neues Intervall festgelegt!", Toast.LENGTH_SHORT).show();
}
catch (Exception e) {
Toast.makeText(getApplicationContext(), "Es wurde noch kein Wert eingegeben!", Toast.LENGTH_SHORT).show();
}
}
});
// Programm beenden
Button exit = (Button)findViewById(R.id.exit);
exit.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
finish();
System.exit(0);
}
});
}
public void onSensorChanged(SensorEvent event){
// Sensor Typ überprüfen
if(event.sensor.getType()==Sensor.TYPE_LINEAR_ACCELERATION){
// Richtungen verknüpfen
float x=event.values[0];
float y=event.values[1];
float z=event.values[2];
// Gerundete Ergebnisse mit vier Nachkommastellen ausgeben
xC.setText("X: "+(Math.abs(Math.round(x * 1000) / 1000.0)));
yC.setText("Y: "+(Math.abs(Math.round(y * 1000) / 1000.0)));
zC.setText("Z: "+(Math.abs(Math.round(z * 1000) / 1000.0)));
// Wenn Beschleunigung über Schwellenwert liegt, starte Timer. Wenn Timer das festgelete Intervall überschreitet, spiele Benachrichtigungston
if (x + y + z > accThreshold)
{
chrono = new Chronometer(this);
chrono.setBase(SystemClock.elapsedRealtime());
chrono.start();
long seconds = ((chrono.getBase()-SystemClock.elapsedRealtime()/1000%60));
if (seconds >= accInterval)
{
Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
Ringtone r = RingtoneManager.getRingtone(getApplicationContext(), notification);
r.play();
}
else
{
chrono.stop();
}
}
}
}
[user=439709]@override[/user]
public void onAccuracyChanged(Sensor sensor, int accuracy) {
// TODO Auto-generated method stub
}
}
activity_accel_meter.xml:
Code:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TableRow tools:ignore="ExtraText" >
<TextView
android:id="@+id/xCoordinate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="X Koordinate: "
android:textAppearance="?android:attr/textAppearanceLarge"
tools:ignore="HardcodedText" />
/>
</TableRow>
<TableRow>
<TextView
android:id="@+id/yCoordinate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Y Koordinate: "
android:textAppearance="?android:attr/textAppearanceLarge"
tools:ignore="HardcodedText" />
/>
</TableRow>
<TableRow>
<TextView
android:id="@+id/zCoordinate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Z Koordinate: "
android:textAppearance="?android:attr/textAppearanceLarge"
tools:ignore="HardcodedText" />
/>
</TableRow>
<EditText
android:id="@+id/threshold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Schwellenwert (float)"
android:inputType="numberDecimal"
tools:ignore="HardcodedText" />
<Button
android:id="@+id/setThreshold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Schwellenwert festlegen"
tools:ignore="HardcodedText" />
<EditText
android:id="@+id/editInterval"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Zeit in Sekunden"
android:inputType="number"
tools:ignore="HardcodedText" >
<requestFocus />
</EditText>
<Button
android:id="@+id/setInterval"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Zeitraum für Überwachung festlegen"
tools:ignore="HardcodedText" />
<Button
android:id="@+id/exit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Beenden"
tools:ignore="HardcodedText" />
</TableLayout>
Yay German code (live there, too) xD Initialise your seconds in your onCreate, it's much nicer and probably the problem. A method gets the highest value the sensor measured would be a simple
Code:
double savedVal=0; //or any other type
private void updateMaxVal(){
double currentVal =// get the value from the specific sensor
if(savedVal<currentVal) {
savedVal = currentVal;
// maybe save the time as well
}
You'd have to put that method in the onsensorchanged so it will be called often. Then update your text View with the new saved value
SimplicityApks said:
Yay German code (live there, too) xD Initialise your seconds in your onCreate, it's much nicer and probably the problem. A method gets the highest value the sensor measured would be a simple
Code:
double savedVal=0; //or any other type
private void updateMaxVal(){
double currentVal =// get the value from the specific sensor
if(savedVal<currentVal) {
savedVal = currentVal;
// maybe save the time as well
}
You'd have to put that method in the onsensorchanged so it will be called often. Then update your text View with the new saved value
Click to expand...
Click to collapse
Hey fellow German!
If I initialise the seconds variable in the onCreate part it says that the variable is not being used (yellow marking) and in the code below I get an error obviously stating that the variable is unknown. ^^
I have three different values, how can I link the x, y and z variables in the method and how can I make sure the variables are known inside of the method? (Same problem as above)
Since I don't know how to do it with a method I just wrote the following code in my onsensorchanged part, the problem is that the max value textviews always show the same as the current value textviews:
float savedValX = 0;
float savedValY = 0;
float savedValZ = 0;
float currentValX = event.values[0];
float currentValY = event.values[1];
float currentValZ = event.values[2];
if (savedValX < currentValX) {
savedValX = currentValX;
xM.setText("X max: "+(Math.abs(Math.round(currentValX * 1000) / 1000.0)));
}
if (savedValY < currentValY) {
savedValY = currentValY;
yM.setText("Y max: "+(Math.abs(Math.round(currentValY * 1000) / 1000.0)));
}
if (savedValZ < currentValZ) {
savedValZ = currentValZ;
zM.setText("Z max: "+(Math.abs(Math.round(currentValZ * 1000) / 1000.0)));
}
Also I still have the problem that my seconds interval is being ignored.
//edit, fixed it! Now I only need the max value method.
OK so I now understand what you are trying to do with your Chronometer, the problem is that you reinitialize it every time the onSensorChanged is called so if you then ask for the seconds it has just started. To fix this, you could set an onChronometerTickListener and set your textViews in that method. To avoid recreating the Chrono use
Code:
if(chrono==null){
chrono = new Chronometer();
chrono.start();
}
If u don't want the tick listener or it doesn't work ( haven't used it yet) you can put your if(seconds<...)in the else {}of above method. But remember that the onSensorChanged is called EVERYTIME the sensor registers a change, this might be very often or just sometimes, so there is no guarantee that the text views will be updated if the else clause in that method is used
PS forget about the initializing of the seconds, I don't know what I was thinking yesterday, but I guess it was too late ...
/*edit:
What I meant with
Code:
double savedVal=0; //or any other type
private void updateMaxVal(){
is that you save your value in your class ("globally"), so that it is accessible to the whole class.
and to do it nicely you can do it like this:
Code:
float savedValX = 0;
float savedValY = 0;
float savedValZ = 0;
boolean change = false;
private void updateMaxVals(SensorEvent event){ // call this method in your onSensorChanged
change = false;
savedValX = getMax(event.values[0], savedValX);
if(change){
xM.setText("X max: "+(Math.abs(Math.round(savedValX * 1000) / 1000.0)));
}
savedValY = getMax(event.values[1], savedValY);
if(change){
yM.setText("Y max: "+(Math.abs(Math.round(savedValY * 1000) / 1000.0)));
}
savedValZ = getMax(event.values[2], savedValZ);
if(change){
yM.setText("Z max: "+(Math.abs(Math.round(savedValZ * 1000) / 1000.0)));
}
}
private float getMax(float currentVal, float savedVal){
if(currentVal > savedVal){
change = true;
return currentVal;
}else{
change = false;
return savedVal;
}
}

Camera Preview

Im trying to start a simple app and i need to display on a SurfaceView the preview of the cam as soon as the App start.
i added the permission to the manifest:
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
and my code:
Code:
import android.content.Context;
import android.hardware.Camera;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
public class MainActivity extends SurfaceView implements SurfaceHolder.Callback{
SurfaceView mSurfaceView;
private SurfaceHolder mHolder;
public Camera camera = null;
public MainActivity(Context context) {
super(context);
mSurfaceView = (SurfaceView) findViewById(R.id.surfaceView);
mHolder = mSurfaceView.getHolder();
mHolder.addCallback(this);
mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
[user=439709]@override[/user]
public void surfaceCreated(SurfaceHolder holder) {
camera = Camera.open();
try{
camera.setPreviewDisplay(mHolder);
} catch(Exception e){
}
}
[user=439709]@override[/user]
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
Camera.Parameters params = camera.getParameters();
params.setPreviewSize(width,height);
camera.setParameters(params);
camera.startPreview();
}
[user=439709]@override[/user]
public void surfaceDestroyed(SurfaceHolder holder) {
camera.stopPreview();
camera = null;
}
}
Ive looked for many tutorial and all technically do the same or smiliart stuff. But the app crashes. I cant find a solution
LogCat
Code:
06-01 12:39:12.456 616-841/system_process I/ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.example.droidcam/.MainActivity bnds=[240,408][240,408]} from pid 861
06-01 12:39:12.596 616-841/system_process D/dalvikvm: GC_FOR_ALLOC freed 1352K, 16% free 11518K/13560K, paused 112ms, total 118ms
06-01 12:39:12.636 2744-2744/? D/dalvikvm: Late-enabling CheckJNI
06-01 12:39:12.646 616-881/system_process I/ActivityManager: Start proc com.example.droidcam for activity com.example.droidcam/.MainActivity: pid=2744 uid=10019 gids={50019, 1006, 1028}
06-01 12:39:12.746 2744-2744/com.example.droidcam E/Trace: error opening trace file: No such file or directory (2)
06-01 12:39:12.826 2744-2744/com.example.droidcam D/dalvikvm: newInstance failed: no <init>()
06-01 12:39:12.836 2744-2744/com.example.droidcam D/AndroidRuntime: Shutting down VM
06-01 12:39:12.836 2744-2744/com.example.droidcam W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x2b5d9930)
06-01 12:39:12.836 2744-2744/com.example.droidcam E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.droidcam/com.example.droidcam.MainActivity}: java.lang.InstantiationException: can't instantiate class com.example.droidcam.MainActivity; no empty constructor
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2223)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2357)
at android.app.ActivityThread.access$600(ActivityThread.java:153)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1247)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5226)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.InstantiationException: can't instantiate class com.example.droidcam.MainActivity; no empty constructor
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1319)
at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2214)
... 11 more
06-01 12:39:12.836 616-1341/system_process W/ActivityManager: Force finishing activity com.example.droidcam/.MainActivity
06-01 12:39:12.986 616-650/system_process D/dalvikvm: GC_FOR_ALLOC freed 1696K, 24% free 10472K/13772K, paused 76ms, total 77ms
06-01 12:39:13.387 616-647/system_process W/ActivityManager: Activity pause timeout for ActivityRecord{2bd8aff0 u0 com.example.droidcam/.MainActivity}
06-01 12:39:18.952 2744-2744/? I/Process: Sending signal. PID: 2744 SIG: 9
06-01 12:39:18.952 616-943/system_process I/ActivityManager: Process com.example.droidcam (pid 2744) has died.
06-01 12:39:19.002 616-616/system_process W/InputMethodManagerService: Window already focused, ignoring focus gain of: [email protected] attribute=null, token = [email protected]
Please put your code into code tags.
EDIT: Thanks.
and Post/check logcats.
just saying it crashes is too vague.
out of ideas said:
and Post/check logcats.
just saying it crashes is too vague.
Click to expand...
Click to collapse
On Eclipse i know how to show the windows of the LogCat, but cant really find it here on Android Studio.
Im a bit newby about this sorry, coming from PHP using just Notepad.
Guess i found it, added log cat
I saw some tutorial like this, im not sure why it doesnt start.
Is it for te onCreate method missing? but i saw that for other works anyway like this
Btw i've also triyed an other way, but stills give me errors. i could upload that one too, different logcat.
Hope one of the two could be solved
Code:
import android.app.Activity;
import android.hardware.Camera;
import android.os.Bundle;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import java.io.IOException;
public class MainActivity extends Activity implements SurfaceHolder.Callback{
/* VARIABILI PRIVATE */
private SurfaceView mSurfaceView;
private SurfaceHolder mSurfaceHolder;
private Camera mCamera;
/** Called when the activity is first created. */
[user=439709]@override[/user]
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mSurfaceView = (SurfaceView)findViewById(R.id.surfaceView);
mSurfaceHolder = mSurfaceView.getHolder();
mSurfaceHolder.addCallback(this);
mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
[user=439709]@override[/user]
public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3) {
Camera.Parameters params = mCamera.getParameters();
params.setPreviewSize(arg2, arg3);
mCamera.setParameters(params);
try {
//lancio la preview
mCamera.setPreviewDisplay(arg0);
mCamera.startPreview();
} catch (IOException e) {
//gestione errore
}
}
[user=439709]@override[/user]
public void surfaceCreated(SurfaceHolder holder) {
mCamera = Camera.open();
}
[user=439709]@override[/user]
public void surfaceDestroyed(SurfaceHolder holder) {
mCamera.stopPreview();
mCamera.release();
}
logcat
Code:
06-01 13:32:31.187 616-661/system_process I/ActivityManager: Start proc com.android.vending for service com.android.vending/com.google.android.finsky.services.ContentSyncService: pid=25552 uid=10005 gids={50005, 3003, 1015, 1028}
06-01 13:32:31.227 25552-25552/com.android.vending E/Trace: error opening trace file: No such file or directory (2)
06-01 13:32:31.387 616-841/system_process I/ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.example.droidcam/.MainActivity bnds=[240,408][240,408]} from pid 861
06-01 13:32:31.437 25566-25566/? D/dalvikvm: Late-enabling CheckJNI
06-01 13:32:31.447 616-1341/system_process I/ActivityManager: Start proc com.example.droidcam for activity com.example.droidcam/.MainActivity: pid=25566 uid=10019 gids={50019, 1006, 1028}
06-01 13:32:31.607 25566-25566/com.example.droidcam E/Trace: error opening trace file: No such file or directory (2)
06-01 13:32:31.787 25552-25552/com.android.vending D/Finsky: [1] FinskyApp.onCreate: Initializing network with DFE https://android.clients.google.com/fdfe/
06-01 13:32:31.987 25552-25552/com.android.vending D/Finsky: [1] DailyHygiene.goMakeHygieneIfDirty: No need to run daily hygiene.
06-01 13:32:32.037 25552-25552/com.android.vending W/Settings: Setting download_manager_max_bytes_over_mobile has moved from android.provider.Settings.Secure to android.provider.Settings.Global.
06-01 13:32:32.037 25552-25552/com.android.vending W/Settings: Setting download_manager_recommended_max_bytes_over_mobile has moved from android.provider.Settings.Secure to android.provider.Settings.Global.
06-01 13:32:32.178 616-881/system_process D/dalvikvm: GC_FOR_ALLOC freed 656K, 26% free 11321K/15124K, paused 82ms, total 86ms
06-01 13:32:32.238 25566-25566/com.example.droidcam D/libEGL: loaded /system/lib/egl/libEGL_adreno200.so
06-01 13:32:32.258 25566-25566/com.example.droidcam D/libEGL: loaded /system/lib/egl/libGLESv1_CM_adreno200.so
06-01 13:32:32.258 25566-25566/com.example.droidcam D/libEGL: loaded /system/lib/egl/libGLESv2_adreno200.so
06-01 13:32:32.268 25566-25566/com.example.droidcam I/Adreno200-EGL: <qeglDrvAPI_eglInitialize:294>: EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_JB.04.01.01.00.036_msm8960_JB_CL2644550_release_AU (CL2644550)
Build Date: 07/31/12 Tue
Local Branch:
Remote Branch: quic/master
Local Patches: NONE
Reconstruct Branch: AU_LINUX_ANDROID_JB.04.01.01.00.036 + NOTHING
06-01 13:32:32.318 25566-25566/com.example.droidcam D/OpenGLRenderer: Enabling debug mode 0
06-01 13:32:32.348 256-515/? I/AwesomePlayer: setDataSource_l(URL suppressed)
06-01 13:32:32.378 256-25622/? D/MediaExtractor: returning default extractor
06-01 13:32:32.388 256-515/? I/AwesomePlayer: setDataSource_l(URL suppressed)
06-01 13:32:32.408 256-25626/? D/MediaExtractor: returning default extractor
06-01 13:32:32.408 256-515/? I/CameraClient: Opening camera 0
06-01 13:32:32.408 256-515/? W/ServiceManager: Permission failure: com.sonyericsson.permission.CAMERA_EXTENDED from uid=10019 pid=25566
06-01 13:32:32.438 256-25630/? I/caladbolg: 3348999538 cald_camctrl.c (6713) 25630 P [SVR] -945967758 + Cald_CamCtrl_PowerUp
06-01 13:32:32.438 256-25630/? I/caladbolg: 3348999630 cald_camctrl.c (7484) 25630 P [SVR] -945967666 + Cald_CamCtrl_FSM_Func_PowerUp
06-01 13:32:32.438 256-25630/? I/caladbolg: 3349003170 cald_hal_qct.c (2789) 25630 P [HAL] -945964126 + Cald_Hal_Qct_If_PowerUp
06-01 13:32:32.438 256-25630/? I/caladbolg: 3349003323 cald_hal_qct.c (2847) 25630 P [HAL] -945963973 - Cald_Hal_Qct_If_PowerUp (0)
06-01 13:32:32.438 256-25630/? I/caladbolg: 3349004665 cald_camctrl.c (7563) 25630 P [SVR] -945962631 - Cald_CamCtrl_FSM_Func_PowerUp (0)
06-01 13:32:32.438 256-25630/? I/caladbolg: 3349004726 cald_camctrl.c (6720) 25630 P [SVR] -945962570 - Cald_CamCtrl_PowerUp (0)
06-01 13:32:32.448 256-25630/? E/caladbolg: 3349014431 cald_camctrl.c (11888) 25630 E [SVR] PreviewSize Invalid param: value[402x527]
06-01 13:32:32.458 25566-25566/com.example.droidcam D/AndroidRuntime: Shutting down VM
06-01 13:32:32.458 25566-25566/com.example.droidcam W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x2b5d9930)
06-01 13:32:32.488 25566-25566/com.example.droidcam E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.RuntimeException: setParameters failed
at android.hardware.Camera.native_setParameters(Native Method)
at android.hardware.Camera.setParameters(Camera.java:1496)
at com.example.droidcam.MainActivity.surfaceChanged(MainActivity.java:41)
at android.view.SurfaceView.updateWindow(SurfaceView.java:580)
at android.view.SurfaceView.access$000(SurfaceView.java:86)
at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:174)
at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:680)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1842)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:989)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4351)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
at android.view.Choreographer.doCallbacks(Choreographer.java:562)
at android.view.Choreographer.doFrame(Choreographer.java:532)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5226)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
at dalvik.system.NativeStart.main(Native Method)
06-01 13:32:32.498 616-943/system_process W/ActivityManager: Force finishing activity com.example.droidcam/.MainActivity
06-01 13:32:32.688 25552-25552/com.android.vending D/Finsky: [1] 2.run: Loaded library for account: [i1YaFxIWaZrcOQ26zxNX5K0RvvY]
06-01 13:32:32.688 25552-25552/com.android.vending D/Finsky: [1] 2.run: Finished loading 1 libraries.
06-01 13:32:32.908 25552-25552/com.android.vending D/Finsky: [1] 5.onFinished: Installation state replication succeeded.
06-01 13:32:33.018 616-647/system_process W/ActivityManager: Activity pause timeout for ActivityRecord{2b946870 u0 com.example.droidcam/.MainActivity}
In Android you normally do not use the constructor of an Activity for anything.
Use the onCreate method instead.
EDIT: The log says that the constructor must be empty.
nikwen said:
In Android you normally do not use the constructor of an Activity for anything.
Use the onCreate method instead.
EDIT: The log says that the constructor must be empty.
Click to expand...
Click to collapse
I thought about that (even if i saw video tutorial doing it) so i tried wht onCreate method and now it seams to give problem with the setParameters?
Ive uploaded the new code and logcats before
Ah. Check this: http://stackoverflow.com/questions/3890381/camera-setparameters-failed-in-android
nikwen said:
Ah. Check this: http://stackoverflow.com/questions/3890381/camera-setparameters-failed-in-android
Click to expand...
Click to collapse
i tryed that at th beggin, and didnt work, in fact i tried it again and still give me the same error apparently
While I'm still learning myself, it looks like you are getting a failed camera permission. And then it tries to pass in an invalid parameter to the camera.
deniel said:
I/CameraClient: Opening camera 0
06-01 13:32:32.408 256-515/? W/ServiceManager: Permission failure: com.sonyericsson.permission.CAMERA_EXTENDED from uid=10019 pid=25566
06-01 13:32:32.448 256-25630/? E/caladbolg: 3349014431 cald_camctrl.c (11888) 25630 E [SVR] PreviewSize Invalid param: value[402x527]
[/CODE]
Click to expand...
Click to collapse
Sent from a Toasted Devil
netwokz said:
While I'm still learning myself, it looks like you are getting a failed camera permission. And then it tries to pass in an invalid parameter to the camera.
Sent from a Toasted Devil
Click to expand...
Click to collapse
But cant understand which one and how should i do. it ryed the 2 ways everybody does
What phone are you trying this on? Have you tried it in an emulator?
After getting home and I was able to try your second piece of code. It looks like it is a problem with <CODE>params.setPreviewSize(arg2, arg3);</CODE>, it doesn't like the width and height arguments. I found THIS(second answer). and after plugging it into your code it was working for me. If you like I can show you the modified code, altho its real easy to plug in.
netwokz said:
After getting home and I was able to try your second piece of code. It looks like it is a problem with <CODE>params.setPreviewSize(arg2, arg3);</CODE>, it doesn't like the width and height arguments. I found THIS(second answer). and after plugging it into your code it was working for me. If you like I can show you the modified code, altho its real easy to plug in.
Click to expand...
Click to collapse
i tryed his first example and finally i get his "distoted" image. When i'll have time ill try the rets thnk u very much
ill try this:
Code:
Camera.Size getBestPreviewSize(int width, int height, Camera.Parameters parameters) {
Camera.Size result=null;
float dr = Float.MAX_VALUE;
float ratio = (float)width/(float)height;
for (Camera.Size size : parameters.getSupportedPreviewSizes()) {
float r = (float)size.width/(float)size.height;
if( Math.abs(r - ratio) < dr && size.width <= width && size.height <= height ) {
dr = Math.abs(r - ratio);
result = size;
}
}
return result;
}
Code:
ublic void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
// Now that the size is known, set up the camera parameters and begin
// the preview.
if (isPreviewRunning) {
mCamera.stopPreview();
}
Camera.Parameters parameters = mCamera.getParameters();
List<Size> sizes = parameters.getSupportedPreviewSizes();
Size optimalSize = getBestPreviewSize( w, h, parameters);
parameters.setPreviewSize(optimalSize.width, optimalSize.height);
mCamera.setParameters(parameters);
mCamera.startPreview();
isPreviewRunning =true;
}
im not sure abot the 3rd parameter of the getBestPreviewSize method which one is it. Like this is still distorted
Yeah, I could never fix the distortion back when I was trying my camera app. But I think I will tinker with it again. Keep this updated if you find anything, I will also.
Sent from a Toasted Devil

Can anyone help me troubleshoot some bluetooth audio skipping? (logcat included)

So I have a Razr M running a deodexed stock rom, on the stock kernel. I am paired to a pair of Motorola S11 Flex HD. Whenever I use Poweramp or PocketCasts, I get audio skipping at the beginning of songs, when I open a menu, or when I poer off the screen. I thought it was my arrghh kernel, but it turns out the issue returned on the stock kernel as well.
here is a log cat, started as soon as I powered on the headphones, through pairing, when the audio skips, and then ended when the audio evens out:
Code:
--------- beginning of /dev/log/main
09-13 15:11:48.215 782 866 E Mot8960 PowerHAL: Error writing to /sys/devices/system/cpu/cpufreq/interactive/boostpulse: No such device
09-13 15:11:48.245 782 866 E Mot8960 PowerHAL: Error writing to /sys/devices/system/cpu/cpufreq/interactive/boostpulse: No such device
09-13 15:11:48.245 782 866 E Mot8960 PowerHAL: Error writing to /sys/devices/system/cpu/cpufreq/interactive/boostpulse: No such device
09-13 15:11:50.757 782 866 E Mot8960 PowerHAL: Error writing to /sys/devices/system/cpu/cpufreq/interactive/boostpulse: No such device
09-13 15:11:50.757 782 866 E Mot8960 PowerHAL: Error writing to /sys/devices/system/cpu/cpufreq/interactive/boostpulse: No such device
09-13 15:11:50.817 782 866 E Mot8960 PowerHAL: Error writing to /sys/devices/system/cpu/cpufreq/interactive/boostpulse: No such device
09-13 15:11:50.817 782 866 E Mot8960 PowerHAL: Error writing to /sys/devices/system/cpu/cpufreq/interactive/boostpulse: No such device
09-13 15:11:50.938 7390 7390 E Trace : error opening trace file: No such file or directory (2)
09-13 15:11:52.119 782 866 E Mot8960 PowerHAL: Error writing to /sys/devices/system/cpu/cpufreq/interactive/boostpulse: No such device
09-13 15:11:52.119 782 866 E Mot8960 PowerHAL: Error writing to /sys/devices/system/cpu/cpufreq/interactive/boostpulse: No such device
09-13 15:11:52.199 782 866 E Mot8960 PowerHAL: Error writing to /sys/devices/system/cpu/cpufreq/interactive/boostpulse: No such device
09-13 15:11:52.199 782 866 E Mot8960 PowerHAL: Error writing to /sys/devices/system/cpu/cpufreq/interactive/boostpulse: No such device
09-13 15:11:52.659 782 866 E Mot8960 PowerHAL: Error writing to /sys/devices/system/cpu/cpufreq/interactive/boostpulse: No such device
09-13 15:11:52.659 782 866 E Mot8960 PowerHAL: Error writing to /sys/devices/system/cpu/cpufreq/interactive/boostpulse: No such device
09-13 15:11:52.669 782 866 E Mot8960 PowerHAL: Error writing to /sys/devices/system/cpu/cpufreq/interactive/boostpulse: No such device
09-13 15:11:52.669 782 866 E Mot8960 PowerHAL: Error writing to /sys/devices/system/cpu/cpufreq/interactive/boostpulse: No such device
09-13 15:11:52.699 782 866 E Mot8960 PowerHAL: Error writing to /sys/devices/system/cpu/cpufreq/interactive/boostpulse: No such device
09-13 15:11:52.699 782 866 E Mot8960 PowerHAL: Error writing to /sys/devices/system/cpu/cpufreq/interactive/boostpulse: No such device
09-13 15:11:52.730 782 866 E Mot8960 PowerHAL: Error writing to /sys/devices/system/cpu/cpufreq/interactive/boostpulse: No such device
09-13 15:11:52.730 782 866 E Mot8960 PowerHAL: Error writing to /sys/devices/system/cpu/cpufreq/interactive/boostpulse: No such device
09-13 15:11:53.620 782 866 E Mot8960 PowerHAL: Error writing to /sys/devices/system/cpu/cpufreq/interactive/boostpulse: No such device
09-13 15:11:53.620 782 866 E Mot8960 PowerHAL: Error writing to /sys/devices/system/cpu/cpufreq/interactive/boostpulse: No such device
09-13 15:11:53.661 782 866 E Mot8960 PowerHAL: Error writing to /sys/devices/system/cpu/cpufreq/interactive/boostpulse: No such device
09-13 15:11:53.661 782 866 E Mot8960 PowerHAL: Error writing to /sys/devices/system/cpu/cpufreq/interactive/boostpulse: No such device
09-13 15:11:53.671 782 866 E Mot8960 PowerHAL: Error writing to /sys/devices/system/cpu/cpufreq/interactive/boostpulse: No such device
09-13 15:11:53.671 782 866 E Mot8960 PowerHAL: Error writing to /sys/devices/system/cpu/cpufreq/interactive/boostpulse: No such device
09-13 15:11:53.691 782 866 E Mot8960 PowerHAL: Error writing to /sys/devices/system/cpu/cpufreq/interactive/boostpulse: No such device
09-13 15:11:53.691 782 866 E Mot8960 PowerHAL: Error writing to /sys/devices/system/cpu/cpufreq/interactive/boostpulse: No such device
09-13 15:11:55.012 782 866 E Mot8960 PowerHAL: Error writing to /sys/devices/system/cpu/cpufreq/interactive/boostpulse: No such device
09-13 15:11:55.012 782 866 E Mot8960 PowerHAL: Error writing to /sys/devices/system/cpu/cpufreq/interactive/boostpulse: No such device
09-13 15:11:55.082 782 866 E Mot8960 PowerHAL: Error writing to /sys/devices/system/cpu/cpufreq/interactive/boostpulse: No such device
09-13 15:11:55.082 782 866 E Mot8960 PowerHAL: Error writing to /sys/devices/system/cpu/cpufreq/interactive/boostpulse: No such device
09-13 15:11:56.654 782 866 E Mot8960 PowerHAL: Error writing to /sys/devices/system/cpu/cpufreq/interactive/boostpulse: No such device
09-13 15:11:56.654 782 866 E Mot8960 PowerHAL: Error writing to /sys/devices/system/cpu/cpufreq/interactive/boostpulse: No such device
09-13 15:11:56.994 782 866 E Mot8960 PowerHAL: Error writing to /sys/devices/system/cpu/cpufreq/interactive/boostpulse: No such device
09-13 15:11:56.994 782 866 E Mot8960 PowerHAL: Error writing to /sys/devices/system/cpu/cpufreq/interactive/boostpulse: No such device
09-13 15:11:58.295 365 668 E ALSAModule: s_standby handle h 0x4121e818
09-13 15:11:58.516 365 668 E ALSAModule: Number of modifiers 0
09-13 15:11:58.516 365 668 E ALSAModule: usecase_type is 0
09-13 15:11:59.076 7438 7438 E Trace : error opening trace file: No such file or directory (2)
09-13 15:12:00.458 7460 7460 E Trace : error opening trace file: No such file or directory (2)
09-13 15:12:00.738 7479 7479 E Trace : error opening trace file: No such file or directory (2)
09-13 15:12:01.909 7525 7525 E Trace : error opening trace file: No such file or directory (2)
09-13 15:12:02.560 7540 7540 E Trace : error opening trace file: No such file or directory (2)
09-13 15:12:03.761 7560 7560 E Trace : error opening trace file: No such file or directory (2)
09-13 15:12:04.052 7573 7573 E Trace : error opening trace file: No such file or directory (2)
09-13 15:12:04.332 7592 7592 E Trace : error opening trace file: No such file or directory (2)
09-13 15:12:05.023 7614 7614 E Trace : error opening trace file: No such file or directory (2)
--------- beginning of /dev/log/system
09-13 15:12:05.153 782 2077 E NotificationService: Ignoring notification with icon==0: Notification(pri=2 contentView=null vibrate=null sound=null defaults=0x0 flags=0x1 kind=[null])
09-13 15:12:05.173 782 1495 E NotificationService: Ignoring notification with icon==0: Notification(pri=2 contentView=null vibrate=null sound=null defaults=0x0 flags=0x1 kind=[null])
09-13 15:12:19.798 7648 7648 E Trace : error opening trace file: No such file or directory (2)
09-13 15:12:20.209 7648 7648 E AmazonMP3_ParentalControls: startInternal threw: null
09-13 15:12:20.209 7648 7648 E ActivityThread: Failed to find provider info for parentalcontrol
09-13 15:12:22.221 782 925 E BluetoothA2dpService.cpp: Retrun val is 2
09-13 15:12:22.241 782 925 E BluetoothA2dpService.cpp: onStatusReply: D-Bus error: org.bluez.Error.NotConnected (Device not Connected)
09-13 15:12:22.241 782 925 E BluetoothA2dpService.cpp: onStatusReply: D-Bus error: org.bluez.Error.NotConnected (Device not Connected)
09-13 15:12:22.241 782 925 E BluetoothA2dpService.cpp: onStatusReply: D-Bus error: org.bluez.Error.NotConnected (Device not Connected)
09-13 15:12:24.253 782 925 E BluetoothA2dpService.cpp: Retrun val is 260
09-13 15:12:26.105 782 866 E Mot8960 PowerHAL: Error writing to /sys/devices/system/cpu/cpufreq/interactive/boostpulse: No such device
09-13 15:12:26.105 782 1342 E Mot8960 PowerHAL: Error writing to /sys/devices/system/cpu/cpufreq/interactive/boostpulse: No such device
09-13 15:12:26.175 782 866 E Mot8960 PowerHAL: Error writing to /sys/devices/system/cpu/cpufreq/interactive/boostpulse: No such device
09-13 15:12:26.175 782 866 E Mot8960 PowerHAL: Error writing to /sys/devices/system/cpu/cpufreq/interactive/boostpulse: No such device
09-13 15:12:27.557 365 7693 E a2dp_audio_hw: _out_buf_thread_func: a2dp_write failed (-110)
09-13 15:12:30.800 1431 1691 E ExternalAccountType: Unsupported attribute readOnly
09-13 15:12:33.603 1498 4096 E Nova.AppsCustomizePagedView: Ignoring widget ComponentInfo{com.motorola.quickview/com.motorola.quickview.browser.BrowserQVWidgetProvider}
09-13 15:12:33.603 1498 4096 E Nova.AppsCustomizePagedView: Ignoring widget ComponentInfo{com.motorola.quickview/com.motorola.quickview.calendar.CalendarQVWidgetProvider}
09-13 15:12:33.603 1498 4096 E Nova.AppsCustomizePagedView: Ignoring widget ComponentInfo{com.motorola.quickview/com.motorola.quickview.contacts.QuickViewWidgetProvider}
09-13 15:12:33.603 1498 4096 E Nova.AppsCustomizePagedView: Ignoring widget ComponentInfo{com.motorola.quickview/com.motorola.quickview.dialer.DialerQVWidgetProvider}
09-13 15:12:33.603 1498 4096 E Nova.AppsCustomizePagedView: Ignoring widget ComponentInfo{com.motorola.quickview/com.motorola.quickview.email.EmailQVWidgetProvider}
09-13 15:12:33.603 1498 4096 E Nova.AppsCustomizePagedView: Ignoring widget ComponentInfo{com.motorola.quickview/com.motorola.quickview.textmessaging.TextMessagingQVWidgetProvider}
Thanks for any ideas.
Code:
a2dp_audio_hw: _out_buf_thread_func: a2dp_write failed (-110)
If I had to guess, that's related...
Sent from my XT907 using Tapatalk 4

sqlite rawquery problem

Hi Guys,I am Developing an Android App for Local Bus Schedule, When Applying a specific Query, My App Crashes in As Soon as it starts.
Here is MY LOG:
Code:
03-12 07:33:54.564: E/SQLiteLog(3580): (1) near "pnotocdm": syntax error
03-12 07:33:54.564: D/AndroidRuntime(3580): Shutting down VM
03-12 07:33:54.564: W/dalvikvm(3580): threadid=1: thread exiting with uncaught exception (group=0x41665c80)
03-12 07:33:54.574: E/AndroidRuntime(3580): FATAL EXCEPTION: main
03-12 07:33:54.574: E/AndroidRuntime(3580): Process: com.arif.pnobusfinder, PID: 3580
03-12 07:33:54.574: E/AndroidRuntime(3580): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.arif.pnobusfinder/com.arif.pnobusfinder.MainActivity}: android.database.sqlite.SQLiteException: near "pnotocdm": syntax error (code 1): , while compiling: SELECT * pnotocdm where KEY_TIME = ?
03-12 07:33:54.574: E/AndroidRuntime(3580): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2215)
03-12 07:33:54.574: E/AndroidRuntime(3580): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2265)
03-12 07:33:54.574: E/AndroidRuntime(3580): at android.app.ActivityThread.access$800(ActivityThread.java:145)
03-12 07:33:54.574: E/AndroidRuntime(3580): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1206)
03-12 07:33:54.574: E/AndroidRuntime(3580): at android.os.Handler.dispatchMessage(Handler.java:102)
03-12 07:33:54.574: E/AndroidRuntime(3580): at android.os.Looper.loop(Looper.java:136)
03-12 07:33:54.574: E/AndroidRuntime(3580): at android.app.ActivityThread.main(ActivityThread.java:5081)
03-12 07:33:54.574: E/AndroidRuntime(3580): at java.lang.reflect.Method.invokeNative(Native Method)
03-12 07:33:54.574: E/AndroidRuntime(3580): at java.lang.reflect.Method.invoke(Method.java:515)
03-12 07:33:54.574: E/AndroidRuntime(3580): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:781)
03-12 07:33:54.574: E/AndroidRuntime(3580): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
03-12 07:33:54.574: E/AndroidRuntime(3580): at dalvik.system.NativeStart.main(Native Method)
03-12 07:33:54.574: E/AndroidRuntime(3580): Caused by: android.database.sqlite.SQLiteException: near "pnotocdm": syntax error (code 1): , while compiling: SELECT * pnotocdm where KEY_TIME = ?
03-12 07:33:54.574: E/AndroidRuntime(3580): at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
03-12 07:33:54.574: E/AndroidRuntime(3580): at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889)
03-12 07:33:54.574: E/AndroidRuntime(3580): at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500)
03-12 07:33:54.574: E/AndroidRuntime(3580): at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
03-12 07:33:54.574: E/AndroidRuntime(3580): at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
03-12 07:33:54.574: E/AndroidRuntime(3580): at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
03-12 07:33:54.574: E/AndroidRuntime(3580): at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
03-12 07:33:54.574: E/AndroidRuntime(3580): at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1314)
03-12 07:33:54.574: E/AndroidRuntime(3580): at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1253)
03-12 07:33:54.574: E/AndroidRuntime(3580): at com.arif.pnobusfinder.DatabaseHandler.getAllBus(DatabaseHandler.java:103)
03-12 07:33:54.574: E/AndroidRuntime(3580): at com.arif.pnobusfinder.MainActivity.onCreate(MainActivity.java:55)
03-12 07:33:54.574: E/AndroidRuntime(3580): at android.app.Activity.performCreate(Activity.java:5231)
03-12 07:33:54.574: E/AndroidRuntime(3580): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
03-12 07:33:54.574: E/AndroidRuntime(3580): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2169)
03-12 07:33:54.574: E/AndroidRuntime(3580): ... 11 more
Here's my Code.
Code:
public class DatabaseHandler extends SQLiteOpenHelper {
// All Static variables
// Database Version
private static final int DATABASE_VERSION = 1;
// Database Name
private static final String DATABASE_NAME = "timetable";
// Bus table name
static final String TABLE_PNOTOCDM = "pnotocdm";
// Bus Table Columns names
private static final String KEY_ID = "id";
private static final String KEY_BUSNAME = "busname";
private static final String KEY_TIME = "time";
...
public List<Pnotocdm> getAllBus() {
List<Pnotocdm> busList = new ArrayList<Pnotocdm>();
// Select All Query
String selectQuery = " SELECT * " + TABLE_PNOTOCDM + " where KEY_TIME = ? " ;
SQLiteDatabase db = this.getWritableDatabase();
Calendar cal = Calendar.getInstance();
int minute = cal.get(Calendar.MINUTE);
int hour = cal.get(Calendar.HOUR);
String time = String.valueOf(hour)+String.valueOf(minute);
Cursor cursor = db.rawQuery(selectQuery, new String[] {time});
// looping through all rows and adding to list
if (cursor.moveToFirst()) {
do {
Pnotocdm bus = new Pnotocdm();
bus.setID(Integer.parseInt(cursor.getString(0)));
bus.setBusName(cursor.getString(1));
bus.setTime(cursor.getString(2));
String name = cursor.getString(1) +"\n"+ cursor.getString(2);
Third.ArrayofName.add(name);
// Adding bus to list
busList.add(bus);
} while (cursor.moveToNext());
}
// return bus list
return busList;
}
I Know the rawquery is wrong but i dont know the Correct Query.
What I Intended is this, The System should compute the Current Time and Check with time Column in the table and Return those values which are greater than the current Time.
The Correct Query Which works in sqlite Browser is
Code:
SELECT busname,time FROM pnotocdm WHERE time>time('now','localtime');
But I dont know how to convert that sql query into java rawquery() method. Please Help
ariftwister said:
Hi Guys,I am Developing an Android App for Local Bus Schedule, When Applying a specific Query, My App Crashes in As Soon as it starts.
Here's my Code.
Code:
public List getAllBus() {
List busList = new ArrayList();
// Select All Query
String selectQuery = " SELECT * " + TABLE_PNOTOCDM + " where KEY_TIME = ? " ;
SQLiteDatabase db = this.getWritableDatabase();
Calendar cal = Calendar.getInstance();
int minute = cal.get(Calendar.MINUTE);
int hour = cal.get(Calendar.HOUR);
String time = String.valueOf(minute)+String.valueOf(hour);
Cursor cursor = db.rawQuery(selectQuery, new String[] {time});
// looping through all rows and adding to list
if (cursor.moveToFirst()) {
do {
Pnotocdm bus = new Pnotocdm();
bus.setID(Integer.parseInt(cursor.getString(0)));
bus.setBusName(cursor.getString(1));
bus.setTime(cursor.getString(2));
String name = cursor.getString(1) +"\n"+ cursor.getString(2);
Third.ArrayofName.add(name);
// Adding bus to list
busList.add(bus);
} while (cursor.moveToNext());
}
// return bus list
return busList;
}
I Know the rawquery is wrong but i dont know the Correct Query.
What I Intended is this, The System should compute the Current Time and Check with time Column in the table and Return those values which are greater than the current Time.
Click to expand...
Click to collapse
Important questions first :
What error do you get ? like a NullPointerException or a CursorIndexOutOfBounds etc.
A standard sql syntax for a query would be
SELECT "Column Name" FROM "TABLE NAME" WHERE "your column" = "desired value" I cant say a word more on the query because i dont know what the variables TABLE_PNOTOCDM and KEY_TIME represent
A structure of your table could make things easier
I think u meant
Code:
String time = String.valueOf(hour)+String.valueOf(minute);
instead of
String time = String.valueOf(minute)+String.valueOf(hour);
and if can spare some time please read http://forum.xda-developers.com/showthread.php?t=2439748
Sent from my GT-S5302 using Tapatalk 2
sak-venom1997 said:
Important questions first :
What error do you get ? like a NullPointerException or a CursorIndexOutOfBounds etc.
A standard sql syntax for a query would be
SELECT "Column Name" FROM "TABLE NAME" WHERE "your column" = "desired value" I cant say a word more on the query because i dont know what the variables TABLE_PNOTOCDM and KEY_TIME represent
A structure of your table could make things easier
I think u meant
Code:
String time = String.valueOf(hour)+String.valueOf(minute);
instead of
String time = String.valueOf(minute)+String.valueOf(hour);
and if can spare some time please read http://forum.xda-developers.com/showthread.php?t=2439748
Sent from my GT-S5302 using Tapatalk 2
Click to expand...
Click to collapse
Sorry For the Inaccurate Details in my Problem, now i have included all the details
ariftwister said:
Sorry For the Inaccurate Details in my Problem, now i have included all the details
Click to expand...
Click to collapse
looks like a syntax error in your raw query
SELECT "Column Name" FROM "TABLE NAME" WHERE "your column" = "desired value"
Sent from my GT-S5302 using Tapatalk 2
sak-venom1997 said:
looks like a syntax error in your raw query
SELECT "Column Name" FROM "TABLE NAME" WHERE "your column" = "desired value"
Sent from my GT-S5302 using Tapatalk 2
Click to expand...
Click to collapse
I got the sql query syntax correct but how to change it to java syntax,?
Sent from my Xperia Mini using Tapatalk 2
ariftwister said:
I got the sql query syntax correct but how to change it to java syntax,?
Sent from my Xperia Mini using Tapatalk 2
Click to expand...
Click to collapse
No dude your SQL syntax is not correct it should look like
String selectQuery = " SELECT * FROM "+TABLE_PNOTOCDM + " WHERE "+KEY_TIME+" = ? " ;
Sent from my GT-S5302 using Tapatalk 2
ariftwister said:
I got the sql query syntax correct but how to change it to java syntax,?
Sent from my Xperia Mini using Tapatalk 2
Click to expand...
Click to collapse
You forgot 'from'
Sent from my GT-S5570 using XDA Premium 4 mobile app
arpitkh96 said:
You forgot 'from'
Sent from my GT-S5570 using XDA Premium 4 mobile app
Click to expand...
Click to collapse
Yes... Thanks...Thats the mistake.. Now the Query is running without any crashes/error. But i dont get the Result i am expecting. I want the rows which is greater than the current time. how to achieve this ?
Code:
SELECT * FROM pnotocdm WHERE time > time('now','localtime');
I want the java query equivalent to the above sql query. Any Help ?
ariftwister said:
Yes... Thanks...Thats the mistake.. Now the Query is running without any crashes/error. But i dont get the Result i am expecting. I want the rows which is greater than the current time. how to achieve this ?
Code:
SELECT * FROM pnotocdm WHERE time > time('now','localtime');
I want the java query equivalent to the above sql query. Any Help ?
Click to expand...
Click to collapse
I think you should firstly check your query in sql then use here.
And your loop maybe the problem.i used like this
while(cursor.moveToNext()){
//get your values
}
Sent from my GT-S5570 using XDA Premium 4 mobile app
^ solved this problem.. Thanks every one.
Sent from my Xperia Mini using Tapatalk 2
I got another problem.
Here's what I'm trying to do,
1. Launch Activity A, Press Button Goto Activity B, Press Button Goto Activity C.
2. Press back button goto Activity B (Activity C is not paused but destroyed)
3. Press button and goto Activity C now again onCreate method is called and activity C is created again.
So why is this happening to my app. I want the activities to pause. How to achieve this?
Thanks in advance.
Sent from my Xperia Mini using Tapatalk 2

Categories

Resources