I need a starting point to make the following possible.
I have a Main activity start when the Android application starts, as well as an alternate screen that I want to be Debug output (only strings). What I am struggling with is, what layout do I use for the debug screen, and how do I keep this screen constantly populating while I am viewing my Main activity? I do not have any code for this functionality as everything I have tried has crashed my application, so I was hoping to start fresh. I am a super noob to Android so any information would be helpful.
Thanks in advance.
EDIT:
I am sorry, I should have been more specific. I will be receiving Debug information over Bluetooth from a robot. Sensor information, location, possibly a camera feed, etc. At the moment I am looking for a good way to display the Debug information that is Text only. I have a Main Activity that will have the controls of the Robot, and I want to have a second separate screen (that can be switched to from the Options menu) that will have the debug information updated in real time. Don't worry about any of the Bluetooth stuff I can already read and write to the socket. Just the "debug screen"
I would suggest using the log associated with each method, listener, etc. you'd like to keep track of. See here: http://developer.android.com/reference/android/util/Log.html
The TAG identifies the aspect you'd like to track in your logCat:
private static final String TAG = "MyActivity";
Then you simply add the following into your methods, listeners, etc.
Log.v(TAG, insert variables and other info here);
You use your app on the device or emulator normally and filter your logCat output for the items your tracking. You can do it simultaneously or inspect you logcat after you've used the app for a bit.
Hope that helps...
I would use the eclipse debugger. The console output as well as logcat are also very useful for debugging.
If you must create your own debug screen I would create an asynctask that can run in the background. Each time you get output that should go to your debugger I would send it to your asynctask and have the asynctask store it in the database along with a time stamp. Then any time you want to view debug output pull up your custom view that pulls data from your database. You could use a LinearLayout that has 6 textviews. The textviews could display the last 6 messages from your debugger. How you implement the layout is really up to you. Just make sure you persist the debug info in your database rather than in memory or I can almost guarantee some of your debug info will be lost.
After doing some more research I have decided to use a TabActivity instead of trying to do two separate screens. This allows the Tabs to be under 1 Activity and I do not need to worry about inter-Activity communication. Thank you all for you help.
Related
How do I access call log for android?
found this but this gives me an access to my existing call log. I want to make private call log in which some specified numbers will be handled.
A "private call log" is simply a list (or ListView activity).
You can use the same layouts and fonts as the "default" android app, but remember that each carrier and manufacturer re-brands the call logs on almost every phone.
So you just need to make your own. You can monitor call logs and remove them if you don't want them duplicated in both logs. See this post:
Delete call log in android for particular number
I want to know how to detect when an external app runs one of this methods. I'm working with some classmates in a project where we want to examinate the response time of other applications. The idea is to measure the time between the run of each method to get an aproximation of the response time when opening the app.
Is this possible to achieve?
Android apps are sandboxed and only expose content that they intend to expose. The methods you name are part of components that cannot be accessed directly from the "outside" world. In other ways, if an app wanted you to know when those methods are being called, they will expose that information (i.e. sending a Broadcast or maybe storing the information in a ContentProvider). You can try and see if you can get some information out of the logcat, but I cannot assure how accurate and consistent it will be.
This is imprecise, but I would monitor logcat activity. Depending on the device/VM/AVD logcat is super active during transitions (such as back-grounding and foregrounding) and idle when an app is awaiting user input.
EDIT:
Other than that, if you can do your analysis off the device, perhaps look into using DDMS?
I'm currently trying to figure out how to do the following:
I want to make a service which will log all the activities / applications (names, their start time, end time and exceptions) also log where the user touched the screen. Is there a way to do it without parsing LogCat ?
Any ideas?
You could build a string of events that occur in each stage of your program, and then write them to a file in the overridden onPause, onDestroy, etc. methods.
see: http://developer.android.com/guide/topics/data/data-storage.html
Either that or learn how to use the intent filters on adb! There are a few tutorials you can use for this.
I am trying to figure out how to turn off the screen from within a service. I have already read this but I am failing to realize how to do this from within a service. I don't really want to deal with wake locks because as soon as the screen goes off, I don't really care about turning it back via java code. I just need a one time method for turning the screen off and I have searched forever on this.
I see two options:
(1) Create a dummy Activity and use it to get a Window object through the getWindow(); method. Then you would use an Intent to call the screen off from your Service.
(2) Use IHardwareService.Stub. Not part of the SDK, but there's a workaround in this blog post: http://www.tutorialforandroid.com/2009/01/changing-screen-brightness.html
BTW: I would strongly recommend the first option. You never know when a class that is not part of the SDK might change.
I am currently working on an Android App which has different service dimensions, such as " service order", "route planning", "photo gallery" and a central login.
so far i implemented each "screen" (and by screen i mean actually the layout of a screen) as a seperate class, which loads a specific layout and handles all listeners and core functionalities such as calling webservices in a thread, receiving answers etc.
I am not quite sure if this is the best way to implemnt mulitiple layout-screens.
The Android dev guideline proposes to use single activities for each "screen layout". However I doubt that this is the most effective way of doing things. Since i need information for each "layout" which are retrieved by the central login (here: a user object). Since an activity (as far as i understand) is a seperate thread, the passing and retrieving of information seems not very practical.
I would like to get your oppinions/feedback on that and thanks for any hint or tip.
So far my structure looks like :
Activity
loads login layout (res/layout/login.xml with setlContentView)
depending on buttonclick other resources are loaded and initialized (means listeners are added etc.)
Greets
Peter
The dev guidelines recommend that for a reason. It IS the most effective way of doing things. You may complain about having to store your data so it can be passed along from activity to activity, but guess what? You're developing an app for a phone! At any point in time, the phone could ring, forcing the user to switch away from your app. Or the user could just choose to temporarily look at a different app. If your app goes back to square one after switching back and lost all data, the user will be understandably angry.
Don't know if this would be suitable for your app, but another option could be to split off the core data handling into a Service, and have your app be just a UI frontend which communicates with that service.