Sent from my Verizon Wireless 4G LTE Smartphone
[email protected] wrote:
Group: http://groups.google.com/group/android-developers/topics
- How to start again if some third party task killer has killed my app ? [1 Update]
- how to query from two unrelated tables and display data in same listview [1 Update]
- Can two applications that run in the same process have different STATIC object values? [3 Updates]
- Camera app bombs, using Android Docs examples. [2 Updates]
- google play store reply comments [1 Update]
- OnStop and OnDestroy aren`t invoked after calling finish() [3 Updates]
- Android Live wallpaper launch in jelly bean [1 Update]
- writing a layout w/ standard ICS buttons [1 Update]
- Android Assets [1 Update]
-
Amit Dwivedi <[email protected]> Dec 26 10:02PM -0800
In my App I have several activities which are obviously related to each
other. Whenever I am on some activity and the user kills my app by using
any task killer. I want to do two things
1. Clear the Notification which I added when the user logged in..
2. finish all the activities other than the first Activity i.e. Login
Activity
Now if user starts again my app either from the recent tasks or from
launcher I want to start from the first activity i.e. Login Activity...
Presently my code works absolutely fine if I use android *manage process* and
end the activity or force close the app from *android task manager*. But if
I am using some other task killer app i.e. Advanced task killer, after
closing the app when I relaunch the App from recent apps the it tries to
restart from the last used Activity instead of Login Activty and gives an
ugly force close error and when I click close it redirects me back to Login
Activity... The Notification is also not cleared when in this case.
How do I handle third party task killers ?
I have read several threads on SO but couldn't get the pointers, few of
them are ...
-
Vijay Krishnan <[email protected]> Dec 27 11:16AM +0530
Hi skink,
cursors point to different tables and tables have different
column names.How do i know that this cursor points to this table?
How do i display data from different tables?
Regards,
vijay.k
-
Erik <[email protected]> Dec 26 03:42PM -0800
On Sunday, December 23, 2012 1:24:08 AM UTC-8, Lew wrote:
> I'm confused by your use of the terms "application" and "process" as
> different things. Each Android app runs in its own process.
This is incorrect. Applications are allowed to share processes. See
http://developer.android.com/guide/components/fundamentals.html.
-Erik
-
Lew <[email protected]> Dec 26 03:51PM -0800
Erik wrote:
>> different things. Each Android app runs in its own process.
> This is incorrect. Applications are allowed to share processes. See
> http://developer.android.com/guide/components/fundamentals.html.
Thank you for that.
--
Lew
-
Lew <[email protected]> Dec 26 03:53PM -0800
Lew wrote:
>> This is incorrect. Applications are allowed to share processes. See
>> http://developer.android.com/guide/components/fundamentals.html.
> Thank you for that.
I see from that link that I was thinking of the common case only:
"By default, every application runs in its own Linux process."
--
Lew
-
JDog <[email protected]> Dec 26 03:01PM -0800
Hello I tried to create a simple camera app with code snippets from the
google android doc's. I dont know what I'm doing wrong but it bombs on
startup. All other code coming from my eclipse ide to android works ok so I
know its not that. I'm old Delphi programmer and know I have much to learn,
but believe it may be in structure of my classes and sub-routines or calls
to surface holder thats screwing it up. Heck it could be my crazy
bracketing lol. it validates ok. If someone can look at please do....
Thank Jay Steele
videorecorder.java
package com.tcs.video;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import com.tcs.video.R.id;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.hardware.Camera;
import android.media.CamcorderProfile;
import android.media.MediaRecorder;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.widget.Button;
import android.widget.FrameLayout;
@SuppressLint("ViewConstructor")
@TargetApi(Build.VERSION_CODES.FROYO)
public class VideoRecorder extends Activity{
/** A safe way to get an instance of the Camera object. */
public static Camera getCameraInstance(){
Camera c = null;
try {
c = Camera.open(); // attempt to get a Camera instance
}
catch (Exception e){
// Camera is not available (in use or does not exist)
}
return c; // returns null if camera is unavailable
}
private Camera mCamera;
private CameraPreview mPreview;
private MediaRecorder mMediaRecorder;
private boolean isRecording = false;
public static final int MEDIA_TYPE_IMAGE = 1;
public static final int MEDIA_TYPE_VIDEO = 2;
private static final String TAG = "";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main1);
// Create an instance of Camera
mCamera = getCameraInstance();
// Create our Preview view and set it as the content of our
activity.
mPreview = new CameraPreview(this, mCamera);
FrameLayout preview = (FrameLayout)
findViewById(R.id.camera_preview);
preview.addView(mPreview);}
private boolean prepareVideoRecorder(){
mMediaRecorder = new MediaRecorder();
// Step 1: Unlock and set camera to MediaRecorder
mCamera.unlock();
mMediaRecorder.setCamera(mCamera);
// Step 2: Set sources
//
mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
// Step 3: Set a CamcorderProfile (requires API Level 8 or
higher)
mMediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));
// Step 4: Set output file
mMediaRecorder.setOutputFile(getOutputMediaFile(MEDIA_TYPE_VIDEO).toString());
// Step 5: Set the preview output
mMediaRecorder.setPreviewDisplay(mPreview.getHolder().getSurface());
// Step 6: Prepare configured MediaRecorder
try {
mMediaRecorder.prepare();
} catch (IllegalStateException e) {
Log.d(TAG, "IllegalStateException preparing
MediaRecorder: " + e.getMessage());
releaseMediaRecorder();
return false;
} catch (IOException e) {
Log.d(TAG, "IOException preparing MediaRecorder: " +
e.getMessage());
releaseMediaRecorder();
return false;
}
return true;
}
private static Uri getOutputMediaFileUri(int type){
return Uri.fromFile(getOutputMediaFile(type));
}
/** Create a File for saving an image or video */
private static File getOutputMediaFile(int type){
// To be safe, you should check that the SDCard is mounted
// using Environment.getExternalStorageState() before doing
this.
File mediaStorageDir = new
File(Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES), "MyCameraApp");
// This location works best if you want the created images to
be shared
// between applications and persist after your app has been
uninstalled.
// Create the storage directory if it does not exist
if (! mediaStorageDir.exists()){
if (! mediaStorageDir.mkdirs()){
Log.d("MyCameraApp", "failed to create directory");
return null;
}
}
// Create a media file name
String timeStamp = new
SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
File mediaFile;
if (type == MEDIA_TYPE_IMAGE){
mediaFile = new File(mediaStorageDir.getPath() +
File.separator +
"IMG_"+ timeStamp + ".jpg");
} else if(type == MEDIA_TYPE_VIDEO) {
mediaFile = new File(mediaStorageDir.getPath() +
File.separator +
"VID_"+ timeStamp + ".mp4");
} else {
return null;
}
return mediaFile;
}
private void releaseMediaRecorder() {
if (mMediaRecorder != null) {
mMediaRecorder.reset(); // clear recorder configuration
mMediaRecorder.release(); // release the recorder object
mMediaRecorder = null;
mCamera.lock(); // lock camera for later use
mCamera.release(); // release the camera for other
applications
mCamera = null;}
// Add a listener to the Capture button
final Button captureButton = (Button) findViewById(id.button_capture);
captureButton.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
if (isRecording) {
// stop recording and release camera
mMediaRecorder.stop(); // stop the recording
releaseMediaRecorder(); // release the MediaRecorder
object
mCamera.lock(); // take camera access back from
MediaRecorder
// inform the user that recording has stopped
//setCaptureButtonText("Capture");
captureButton.setText("Capture");
isRecording = false;
} else {
// initialize video camera
if (prepareVideoRecorder()) {
// Camera is available and unlocked, MediaRecorder
is prepared,
// now you can start recording
mMediaRecorder.start();
// inform the user that recording has started
// setCaptureButtonText("Stop");
captureButton.setText("Stop");
isRecording = true;
} else {
// prepare didn't work, release the camera
releaseMediaRecorder();
// inform user
}
}
}
}
);
}
}
Camerapreview.java
package com.tcs.video;
import java.io.IOException;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.hardware.Camera;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.SurfaceView;
import android.view.View;
import android.widget.Button;
import android.view.SurfaceHolder;
@TargetApi(Build.VERSION_CODES.FROYO)
/** A basic Camera preview class */
public class CameraPreview extends SurfaceView implements
SurfaceHolder.Callback {
private SurfaceHolder mHolder;
private Camera mCamera;
private static final String TAG = "";
public CameraPreview(Context context, Camera camera) {
super(context);
mCamera = camera;
// Install a SurfaceHolder.Callback so we get notified when the
// underlying surface is created and destroyed.
mHolder = getHolder();
mHolder.addCallback(this);
// deprecated setting, but required on Android versions prior to 3.0
mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
public void surfaceCreated(SurfaceHolder holder) {
// The Surface has been created, now tell the camera where to draw
the preview.
try {
mCamera.setPreviewDisplay(holder);
mCamera.startPreview();
} catch (IOException e) {
Log.d(TAG, "Error setting camera preview: " + e.getMessage());
}
}
public void surfaceDestroyed(SurfaceHolder holder) {
// empty. Take care of releasing the Camera preview in your
activity.
}
public void surfaceChanged(SurfaceHolder holder, int format, int w, int
h) {
// If your preview can change or rotate, take care of those events
here.
// Make sure to stop the preview before resizing or reformatting it.
if (mHolder.getSurface() == null){
// preview surface does not exist
return;
}
// stop preview before making changes
try {
mCamera.stopPreview();
} catch (Exception e){
// ignore: tried to stop a non-existent preview
}
// set preview size and make any resize, rotate or
// reformatting changes here
// start preview with new settings
try {
mCamera.setPreviewDisplay(mHolder);
mCamera.startPreview();
} catch (Exception e){
Log.d(TAG, "Error starting camera preview: " + e.getMessage());
}
}
main1.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
<FrameLayout
android:id="@+id/camera_preview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
/>
<Button
android:id="@+id/button_capture"
android:text="Capture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
/>
</LinearLayout>
-
TreKing <[email protected]> Dec 26 05:16PM -0600
> I dont know what I'm doing wrong but it bombs on startup.
You can't just tell us "it bombs" and post your code and hope someone will
debug this for you. Have you debugged this at all? Do you at least have a
stacktrace with an error that tells more about "the bomb" ?
-------------------------------------------------------------------------------------------------
TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
transit tracking app for Android-powered devices
-
TreKing <[email protected]> Dec 26 05:10PM -0600
> Why I can not reply comments to my app in store?
You are not one of Google's hand-picked special developers that can acquire
such privileges. Welcome to the club!
Is there anyway to reply?
1 - Become one of the aforementioned special developers OR
2 - Wait until the feature becomes available for us mere mortals.
-------------------------------------------------------------------------------------------------
TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
transit tracking app for Android-powered devices
-
RichardC <[email protected]> Dec 26 02:30PM -0800
Have you experimented with "Don't keep activities" in Settings > Developer
options?
On Wednesday, December 26, 2012 4:17:06 PM UTC, latimerius wrote:
-
Latimerius <[email protected]> Dec 26 11:36PM +0100
On Wed, Dec 26, 2012 at 11:30 PM, RichardC
> Have you experimented with "Don't keep activities" in Settings > Developer
> options?
Nope, I haven't touched that (yet).
-
TreKing <[email protected]> Dec 26 05:06PM -0600
> http://stackoverflow.com/questions/7536988/android-app-out-of-memory-issues-tried-everything-and-still-at-a-loss/7576275#7576275
> If you can provide a sample app and steps for reproducing the
> activities-get-destroyed-for-memory behavior, I'd love to see it!
Interesting. Thanks for the link. I was going off the docs you mention in
the post. Though I swear I saw this behavior on my G1 ... I'll play around
with it when I get back from vaca and post back.
-------------------------------------------------------------------------------------------------
TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
transit tracking app for Android-powered devices
-
bob <[email protected]> Dec 26 02:28PM -0800
Please see this site:
*
http://www.vogella.com/articles/AndroidLiveWallpaper/article.html#overview_setting
*
On Wednesday, December 26, 2012 5:44:33 AM UTC-6, djhacktor wrote:
-
Mark Murphy <[email protected]> Dec 26 03:04PM -0500
> can this be done while maintaining compatibility with pre v11.
Either:
-- do not specify a custom theme, or
-- specify a set of custom themes, set for the different API levels
You can see the latter in action if you create a project in Eclipse
and have the new-project wizard create an activity for you. In fact, I
just wrote up a related StackOverflow answer earlier today:
http://stackoverflow.com/questions/14043543/what-does-the-appbasetheme-do-in-android-apps/14043632#14043632
--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy
Aqui estão alguns sites onde você pode perguntar ou responder dúvidas
sobre desenvolvimento de aplicações para Android:
http://www.andglobe.com
-
Nikolay Elenkov <[email protected]> Dec 26 06:37PM +0900
On Wed, Dec 26, 2012 at 5:27 PM, Shubham Aggarwal
> process user's bitmap image.
> So, rather than sending the data for both I would like to send the data for
> only user's image.
That still doesn't make much sense, at least to me. You have to read something
from disk, Java or C doesn't usually matter, especially since some of the Java
I/O routines are done in native code anyway. What you do afterwards with that
data is another matter altogether.
At any rate, what the asset manager does it read some compressed data from
the APK, and if you look at the code for AssetManager, etc. you should be able
to reproduce it in native code, if that is really what you want. IIRC,
some (most?)
of it is natvie already. Or, just copy the thing to a regular file
using Java code on
first run an use normal fopen(), etc..
You received this message because you are subscribed to the Google Group android-developers.
You can post via email.
To unsubscribe from this group, send an empty message.
For more options, visit this group.
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en --
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

