Author: Yassin Matan
President
Somforce Inc.
...
##########################################################################
----THIS IS A NEW SITE.....STILL UNDER DEVELOPMENT...ANY HELP WILL BE APPRECIATED----
****** IF YOU LIKE WHAT YOU SEE, PLEASE REGISTER AND CONTRIBUTE YOUR OWN LINKS / REFERENCES / NOTES ETC.. ********
DON'T FORGET TO CHECK OUT THE REST OF THE SITE FOR MORE USEFUL INFO...
I am donating my time to develop a centralized Android Web Notes/Ideas/Tutorials/Code/Documents/References/All Android Web Sites...In ONE place etc
These are my own Android web notes I gathered for my App Developments. They are not in any order. I also attached several files that I found on the web that may help you learn more. I will add more
Enjoy.
###########################################################################
ALL TUTORIALS HOW TOHOT HOT HOT....just weeks old tutorials
http://marakana.com/forums/android/android_examples/Also more...
BEST ==> Source Code to _Android Programming Tutorials (Thanks to Commonsguy at...
http://commonsware.com/AndTutorials/ )
You can download each tutorial on the upper right hand corner (Download Source button)
http://github.com/commonsguy/cw-andtutorialsOTHER TUTORIALS HOW TOhttp://www.codebeach.com/tag/android,tu ... 70098885/2and
http://androidcommunity.com/forums/f4/w ... -here-137/And/or
and mixture of tutorials
http://saigeethamn.blogspot.com/2009/08 ... l-for.htmlMore great tutorials
http://blog.pocketjourney.com/category/tutorials/More code and tutorials
http://www.droidnova.com/category/how-toand more
http://www.dreamincode.net/forums/showforum129.htmGoogle app - API Demos
http://d.android.com/resources/samples/ ... index.htmlAndroid 2.1 Development with Eclipse 3.5 - Tutorial...
http://www.vogella.de/articles/Android/article.htmlAndroid 2.0 Features Snapshot
http://www.aboutonlinetips.com/android- ... -snapshot/Android 2.0 screenshot walkthrough
http://www.boygeniusreport.com/2009/10/ ... lkthrough/More great tutorials...(see bottom of the site..)
http://developerlife.com/tutorials/?p=309See This new Site...It has many screen demos...http://vidarvestnes.blogspot.com/2010/0 ... mples.htmlAlso more nice sample codes/tutorialshttp://www.androidpeople.com/category/android-tutorial/Get Android 2.0 Source from herehttp://source.android.com/downloadAll Android Phones out there now. Wow, great comparison CHARThttp://www.androphones.com/all-android-phones.php@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
List of some of the Android Development Books out there -- I have the first 8 books...
I like the first 4 books because they provide....
- In depth explanation,
- Sample code,
- Project screen shots,
- Enough projects and code,
- Code Completion in the book,
- Hints and Directions
THE BEST OUT THERE (The first 4 books are the best I have seen)
1
Professional Android Application Development (by Reto Meier, published by Wrox)
2
Beginning Android (by Mark Murphy, published by Apress)
3
The Busy Coder's Guide to Android Development (by Mark Murphy, published by CommonsWare)
4
Android Programming Tutorials (by Mark Murphy, published by CommonsWare)
-------------->
5
Android: A Programmer's Guide (by Jerome DiMarzio, published by McGraw-Hill Osborne Media)
6
Android Wireless Application Development (by Shane Condor & Lauren Darcey, published by Addison-Wesley Professional)
7
The Busy Coder's Guide to Advanced Android Development (by Mark Murphy, published by CommonsWare)
8
Unlocking Android (by Frank Ableson, Charlie Collins, and Robi Sen; published by Manning Publications)
9
Pro Android (by Sayed Hashimi, published by Apress)
10
Pro Android Games (by Vladimir Silva, published by Apress)
11
Android Essentials (by Chris Haseman, published by APress)
12
Hello, Android (by Ed Burnette, published by Pragmatic Programmers)
13
Android Application Development (by Rick Rogers, John Lombardo, Zigurd Mednieks, Blake Meike; published by O'Reilly & Associates)
FREE E-BOOK
http://commonsware.com/Android/Android-1_0-CC.pdf@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Android Live Wallpaper tutorial for Android 2.1...http://blog.androgames.net/58/android-l ... -tutorial/Android Wall Papers
http://www.talkandroid.com/wallpapers/----------------------------------------------------------------------------------------------------
For background image changes from...PORTRAIT to LANDSCAPE
http://androidcommunity.com/forums/f7/b ... fix-29408/LANDSCAPE
Phone = 480 x 320
Image = 480 x 320
and
PORTRAIT
Phone = 320 x 480
Image = 480 x 320
-----------------
JSON TUTORIALhttp://devstream.stefanklumpp.com/2009/ ... nt-to.htmlVideo recordinghttp://groups.google.com/group/android- ... f24049c13dImage GridView tutorialhttp://developer.android.com/guide/tuto ... dview.htmlTake a picturehttp://stackoverflow.com/questions/4558 ... rom-cameraCAMERA TAKES IMAGE AND SEND IT TO SERVERhttp://vikram.eggwall.com/computers/watchtower.htmlhttp://www.tomgibara.com/android/camera-source...and SEE THIS
http://www.mail-archive.com/android-dev ... 73057.htmlAndroid transitions- slide in and slide outUSING INCLUDE TAG TO IMPORT OTHER XML FILES FROM THE SAME DIRECTORY
http://www.inter-fuser.com/2009/07/andr ... slide.htmlStart different activities in separate tabs of a TabHosthttp://www.androidsnippets.org/snippets/68/Showing indeterminate progress bar in TabHost activityhttp://stackoverflow.com/questions/1138 ... t-activity----
Understanding Android Themes and Styleshttp://brainflush.wordpress.com/2009/03 ... nd-styles/ListView and ListActivity Demohttp://maohao.wordpress.com/2009/11/26/ ... vity-demo/and
Clickable ListView Itemshttp://www.androidsnippets.org/snippets/125/How to display list of images in ListView in androidhttp://stackoverflow.com/questions/4597 ... in-androidAndroid: ListView with complex data modelhttp://stackoverflow.com/questions/1595 ... data-modelDisplay images that are stored on your SD card.http://mihaifonoage.blogspot.com/2009/1 ... rd-in.htmlHow to store images larger than 1 megabyte in Google App Enginehttp://www.rezendi.com/pa/labels/AppEngine.html---
DYNAMIC UI http://www.dreamincode.net/forums/showtopic130521.htmAND THIS
http://caguilartech.blogspot.com/2009/0 ... s-and.html---
Ticketing System Examplehttp://www.linux-mag.com/cache/7463/1.htmland also see
Hands-on: Multiple Activities and Data Persistence in Android
http://www.linux-mag.com/cache/7498/1.htmlWriting
--
MENUS...Official site
Creating Menushttp://developer.android.com/guide/topics/ui/menus.htmlHow to create an option menuhttp://www.droidnova.com/how-to-create- ... u,427.htmlDynamically change Options Menu Items in Androidhttp://thedevelopersinfo.com/2009/10/20 ... n-android/Menu item creation codehttp://developerlife.com/tutorials/?p=304Creating Game Menus in Androidhttp://www.droidnova.com/creating-game- ... d,518.htmlGetting Started in Android Game Development http://blog.vn-dev.net/2010/01/getting- ... -game.htmlAndroid 3D game tutorialhttp://www.droidnova.com/android-3d-gam ... i,312.htmlAndroid Animations 3D fliphttp://www.inter-fuser.com/2009/08/andr ... -flip.htmland more 3d image fliphttp://www.anddev.org/viewtopic.php?p=29493more samples of this sitehttp://www.inter-fuser.com/--
The Android Modeller and Code GeneratorCreate Android apps without programming??? (I have not tested this yet...)
http://www.lab.telin.nl/~msteen/andromate/and also see
http://www.designerandroid.com/and
http://googleresearch.blogspot.com/2009 ... droid.html----------
Showing Toast in Androidhttp://thedevelopersinfo.com/2009/10/23 ... n-android/----------
Databases and Menushttp://www.dreamincode.net/forums/showtopic130762.htmVIEWFLIPPER AND TAB VIEWhttp://www.androidguys.com/2008/08/14/f ... our-views/http://www.androidguys.com/2008/08/12/a ... namically/I THINK BEST VIEW FLIPPER IS HEREhttp://www.inter-fuser.com/2009/07/andr ... slide.htmland this (test flip)
http://osdir.com/ml/Android-Developers/ ... 02457.htmlMORE APPS
http://www.androidguys.com/category/ag- ... ng-droids/#########################
TIP1:To stop your activity from restarting when phone orientation changes do...
In manifest.xml under Activity put...
android:configChanges="orientation|keyboardHidden"
and in your app
import android.content.res.Configuration;
and implement
@Override
public void onConfigurationChanged(Configuration newConfig) {
// TODO Auto-generated method stub
super.onConfigurationChanged(newConfig);
}
TIP2:
10 User Experience Tips for Successful Android Apps http://www.androidtapp.com/10-user-expe ... roid-apps/#########################
TOUCH SCREEN OR GESTURE TOUCHhttp://www.anddev.org/viewtopic.php?p=29945WINDOWS UI BACKGROUNDShttp://android-developers.blogspot.com/ ... speed.htmlNICE TUTORIALhttp://www.2linessoftware.com/2009/01/1 ... 1/#more-23http://www.androidph.com/2008/11/camera-capture.htmlsource code
http://mobileserver.byethost2.com/?p=45THIS TUTORIAL IS JUST BEAST. (NETWORK, GPS, CAMERA, RADAR ETC...)
http://www.androidph.com/2009/02/app-10-beer-radar.htmlRADAR...STEP BY STEPhttp://www.androidph.com/2009/02/app-10-beer-radar.htmlSOURCE CODEhttp://mobileserver.byethost2.com/?attachment_id=96RADAR.http://groups.google.com/group/android- ... ba87263bb5MAPSBest MAP TUTORIAL
http://mobiforge.com/developing/story/u ... ps-androidand
http://2009.hfoss.org/Tutorial:Hello_Mapview,_with_GPSOPENGL ANIMATION FOR RADAR.http://en.oreilly.com/oscon2009/public/ ... etail/8108CHANGES TO JAVA 1.5 NOTES
http://page.mi.fu-berlin.de/oezbek/pub/ ... va_1.5.pdfINTRO TO ANDROIDhttp://static.kazed.net/dist/android-pr ... andout.pdfand
http://www.datasprings.com/Resources/Ar ... eCode.aspxLive Camera Previews in Androidhttp://www.tomgibara.com/android/camera-sourceSERVICE ORIENTED TUTORIAL (Backgroud services)
http://developerlife.com/tutorials/?p=300Development and remote installation of Java service for the Android Devices (Nice) http://www.codeproject.com/KB/mobile/an ... pment.aspxHOW TO SIGN YOUR ANDROID APPhttp://www.brighthub.com/mobile/google- ... 40857.aspxhttp://www.brighthub.com/mobile/google- ... 40859.aspx------------------
BEST...PERIOD...
ASK ANDROID DEVELOPER QUESTIONS HEREBest forum out there...
http://www.anddev.organd/or
http://www.stackoverflow.comand other forums
http://androidforums.com/more
http://www.rbgrn.net/content/187-ask-al ... tions-here-------------------
IBM ANDROID SENSORShttp://www.ibm.com/developerworks/opens ... index.htmlSENSOR
BEST SENSOR CODEhttp://www.anddev.org/viewtopic.php?p=22675AND
http://www.anddev.org/viewtopic.php?p=26929SAMPLE SENSOR NICE AND CAMPUS SAMPLE AS WELLhttp://www.anddev.org/accessing_the_acc ... 9-s45.htmlAND
http://mysticlakesoftware.blogspot.com/NICE SENSOR CODEhttp://android.hlidskialf.com/post/andr ... n-listenerWORKING SENSOR CODE NICE NICE AND DETECT SHAKEhttp://www.anddev.org/viewtopic.php?p=27383OFFICIAL SITE FOR SENSORhttp://code.google.com/p/cellphone-sonar/Nice sensorshttp://stuffthathappens.com/blog/2009/0 ... d-sensors/THIS SENSOR IS THE ONE YOU NEED FOR THE APPhttp://www.codeshogun.com/blog/2009/04/ ... id-part-i/Tutorials sensorshttp://www.linuxfordevices.com/c/a/News ... -tutorial/------------
Table Layouthttp://developerlife.com/tutorials/?p=307PASSING OBJECT FROM ONE ACTIVITY TO ANOTHER.http://thinkandroid.wordpress.com/2009/ ... ctivities/THIS SITE HAS MANY THINGS, INCLUDING (PHOTO GALLERY TUTORIAL, SEARCH IT THOUGH ON THE SITE)
http://www.brighthub.com/mobile/google- ... 42185.aspxThe link above is dialogs, but it mentions about photo gallery
REDRAW A VIEWhttp://groups.google.com/group/android- ... d35e5e5c15calls invalidate method...
Officialhttp://developer.android.com/reference/ ... /View.html=================================================================
Game exampleshttp://github.com/eburke/android_game_examplesAnimationshttp://www.inter-fuser.com/2009/08/andr ... -flip.htmlhttp://www.netmite.com/android/mydroid/ ... animation/Android 3D Flip Animationhttp://www.inter-fuser.com/2009/08/andr ... -flip.htmlNICE ICONS, IMAGES, DRAWABLEShttp://www.everaldo.com/crystal/?action=downloadsand/or
http://www.screaming-penguin.com/info/a ... ables.htmlAND...MORE NICE.........DRAWABLEShttp://www.small-icons.com/index.htm--------------------------------------------
IMAGE GALLERYhttp://www.netmite.com/android/mydroid/ ... llery.javaAndroid Tutorial: Image & Text-Only Buttons
http://blog.pocketjourney.com/2008/04/3 ... y-buttons/INSTALL APPS ON DEV 1 PHONEhttp://www.anddev.org/debugging-install ... t3236.htmlUSB DRIVERS WELL ARE FOUND HERE...
ROOTING YOUR G1 DEV 1 PHONE (step by step)
http://android.noisepages.com/2009/05/p ... esusfreke/Hot to Root Videohttp://theunlockr.com/2009/10/15/how-to ... droid-1-6/How to Hack Your Android Phone (and Why You Should Bother)http://www.readwriteweb.com/archives/ho ... _phone.php----------
"One" of the BEST ANDROID SITE OUT THERE
http://www.androidandme.comANDROID DEV 1 PHONE RETURN POLICYhttp://www.google.com/support/forum/p/A ... 86b3&hl=en------------------
FILEShttp://www.anddev.org/working_with_files-t115-s30.htmlNICE FILE ONE
http://androidforums.com/android-develo ... droid.htmlhttp://bestsiteinthemultiverse.com/2008 ... nt-page-1/CHECK THIS ONE
http://www.anddev.org/viewtopic.php?p=27514and
generic file...
http://www.daniweb.com/forums/thread123311.htmlDELETING FILE IN ANDROID
http://stackoverflow.com/questions/1248 ... om-sd-cardAlso this one has good and complete code
http://www.higherpass.com/java/Tutorial ... With-Java/CHECK FILE EXISTS
http://www.higherpass.com/java/Tutorial ... With-Java/FILE CODE SAMPLES
WRITING/READING/DELETING/MOVING/APPENDING
http://www.higherpass.com/java/Tutorial ... With-Java/APPENDING TO A FILE
http://groups.google.com/group/android- ... cbd733bf68sample from site
FileOutputStream out
= context.openFileOutput("test.txt", Context.MODE_APPEND);
AND
RANDOM FILE ACCESS IS WHAT YOU NEED
http://www.java-tips.org/java-se-tips/j ... -file.htmlhttp://www.higherpass.com/java/Tutorial ... th-Java/2/some file ideas
http://stackoverflow.com/questions/1756 ... -text-fileSD card file
http://www.blog.droidweb.com/?tag=read-filesLocal File system URI
http://www.techjini.com/blog/2009/01/10 ... g-content/FILE GUI SAMPLE..USE THE DIALOGUE BOX WITH TWO BUTTONS
http://lysesoft.com/products/andexplorer/index.html#############################
ACCELEROMETERhttp://androidforums.com/android-develo ... -code.htmlSOURCE CODE SAMPEShttp://examples.oreilly.com/9780596521509/--------
ZONE LIST...
Test this code some time...
http://gitorious.org/easyweb2/packages- ... eList.java--------
MEDIA CLASShttp://groups.google.com/group/android- ... 2adb82663aIMAGEShttp://www.developer.com/java/j2me/arti ... ndroid.htmNICE @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
TAKE PICTURE VIA CAMERA AND PUT THEM IN GALLERYCODE FOR IMAGE GALLERY
Tutorial:Camera and Gallery Demo
http://2009.hfoss.org/Tutorial:Camera_and_Gallery_Demo@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
and
OFFIAL
http://developer.android.com/guide/tuto ... llery.htmlTHE ABOVE LINK CODE MAY HAVE PROBLEM...
SOLUTION IS
http://pdf.jpedal.org/java-pdf-blog/bid ... ry-problemOTHER image gallery
http://www.anddev.org/gallery_with_remo ... -t769.htmlApplying Styles and Themes
http://developer.android.com/guide/topi ... hemes.htmlDIALOGUESNICEST TUTORIAL EVER
http://www.anddev.org/tutorial_modal_dialogs-t4325.htmlTIMED DIALOGUE POPUP
http://stackoverflow.com/questions/4542 ... in-androidComplex Dialog BOX
http://www.brighthub.com/mobile/google- ... 42185.aspxmore...
http://android.ifies.org/tutorial/2009/ ... le-dialogshttp://developer.android.com/guide/topi ... stomDialoghttp://bestsiteinthemultiverse.com/2009 ... n-example/http://developmentality.net/post/229136 ... x-tutorialAND
with STYLES
http://www.anddev.org/bosicc_custom_ale ... t7928.htmlhttp://androidsamples.blogspot.com/2009 ... arser.htmlHOW TOs MANY THINGS...INTERESTINGhttp://www.frickingnutz.com/files/android_pdf/FAQs.pdf------------------
SCREEN TO SCREEN WITH BUTTONhttp://www.anddev.org/screen_to_next_sc ... t5341.htmlScrolling with buttonhttp://bestsiteinthemultiverse.com/2009 ... n-example/SPLASH SCREEN GOOD***http://www.droidnova.com/how-to-create- ... n,561.htmlGOOD ANDROID TUTORIAL SITEhttp://www.dreamincode.net/forums/index ... pic=130264BEST...
Go Public with Your Android Application: Signing and Deployment http://www.devx.com/wireless/Article/39972/1954SIGNING AND PUBLISHING YOUR APP
http://www.brighthub.com/mobile/google- ... 40899.aspxand/or
http://www.dreamincode.net/forums/showtopic131121.htmUI WIDGET GUIDEhttp://www.droiddraw.org/widgetguide.htmlLayout Tricks: Using ViewStubshttp://d.android.com/resources/articles ... stubs.htmlDYNAMIC UIshttp://www.dreamincode.net/forums/showtopic130521.htmGOOD UI DESIGNS
http://mobiforge.com/designing/story/un ... -1-layoutsLayouts / over lay textview over an image
http://www.curious-creature.org/2009/02 ... -tricks-1/and
http://www.curious-creature.org/2009/03 ... ze-part-1/THIS IS TOO NICE OF A LAYOUT SITE PROGRAMMINGAlso
http://www.netmite.com/android/mydroid/ ... ckage.htmlANDROID SEND MAIL...
http://www.vidyut.com/sunit/android/and ... dmail.htmlService Enabled Androidhttp://developerlife.com/tutorials/?p=289TOUCH SCREENShttp://www.warriorpoint.com/blog/2009/0 ... ch-screen/Just Interestinghttp://www.madfellas.com/blog/index.cfm ... s--AmazingClickable Listshttp://www.androidsnippets.org/snippets/125/An introduction to Text-To-Speech in Androidhttp://android-developers.blogspot.com/ ... ch-in.htmlhttp://android-mobile-device.com/2009/0 ... n-android/TAKE A PICTUREhttp://www.damonkohler.com/2009/02/android-recipes.htmlthis above code can be used to integrate in the ARMitPro to
take a picture as the phone is flipped upside down and send it via email or sms.
ALSO, this site has many more examples
GPS LOCATIOn, etc
VIBRATE
SENSORS
SMS
SILENT RINGER...enable or disable ringer
NICE GPS WHERE ARE MY FRIENDS PROGRAMMING
http://blogoscoped.com/archive/2008-12-15-n14.html--HERE also set ringer and some other ideas
http://gitorious.org/easyweb2/packages- ... tings.java--------
ANDROID DEEP INSIDE PAPER
http://www.openexpo.ch/fileadmin/docume ... ntemps.pdfSOUNDS.OFFICIAL AUDIO API
http://docs.androidside.com/docs/refere ... nager.htmland
http://tkcodesharing.blogspot.com/2009/ ... sound.htmlMore sound reference
http://stackoverflow.com/questions/6286 ... ndroid-appand
http://www.google.com/search?hl=en&q=an ... f&oq=&aqi=Custom Audio Streaming with MediaPlayer
http://blog.pocketjourney.com/2008/04/0 ... diaplayer/MUSIC PLAYER APPLICATION / SAMPLE CODE / PROJECT (Nice)
http://www.helloandroid.com/tutorials/m ... yer-part-iWATCHOUT...SOUND FIX FOR ANDROID 2.0
http://groups.google.com/group/android- ... c?lnk=raotAUDIO STREAMING
http://blog.pocketjourney.com/2008/04/0 ... diaplayer/GAME SOUND CODEhttp://groups.google.com/group/android- ... 96bf87eb8eAdding sound and music to an android game
http://karanar.net/?p=25###############################################################
EXTRAS TO SEARCH
- TransitionDrawable...transsition backgrounds
http://groups.google.com/group/android- ... 2?lnk=raotPlaying with Graphics
http://www.droidnova.com/playing-with-g ... i,147.html----------------------
SENSOR CODE
package org.android.sample;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.hardware.Sensor;
import android.os.Bundle;
import android.widget.TextView;
public class HelloAccelerometer extends Activity{
private TextView mTxtView;
private SensorManager mSensorManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
mSensorManager = (SensorManager)getSystemService(Context.SENSOR_SERVICE);
mSensorManager.registerListener(mSensorListener, mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),
SensorManager.SENSOR_DELAY_FASTEST);
mTxtView = new TextView(this);
setContentView(mTxtView);
}
public void updateTV(float p_x, float p_y, float p_z)
{
mTxtView.setText("x: "+p_x+", y: "+p_y+", z: "+p_z);
}
private final SensorEventListener mSensorListener = new SensorEventListener() {
public void onSensorChanged(SensorEvent se)
{
float x = se.values[0];
float y = se.values[1];
float z = se.values[2];
updateTV(x, y , z);
}
public void onAccuracyChanged(Sensor sensor, int accuracy) {}
};
@Override
protected void onResume()
{
super.onResume();
mSensorManager.registerListener(mSensorListener, mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_FASTEST);
}
@Override
protected void onStop()
{
mSensorManager.unregisterListener(mSensorListener);
super.onStop();
}
}
########################################
USING INCLUDE TAG TO IMPORT OTHE XML FILES FROM THE SAME DIRECTORY
http://www.inter-fuser.com/2009/07/andr ... slide.htmlBELOW IS PART OF THE SITE.
Define a layout with a ViewFlipper
First of all we are going to edit the main.xml layout file in the res/layout directory of the our new android application here it is:
view sourceprint?01.<?xml version="1.0" encoding="utf-8"?>
02.<ViewFlipper xmlns:android="http://schemas.android.com/apk/res/android"
03.android:id="@+id/flipper"
04.android:layout_width="fill_parent"
05.android:layout_height="fill_parent"
06.>
07.<include android:id="@+id/first" layout="@layout/first_view" />
08.<include android:id="@+id/second" layout="@layout/second_view" />
09.</ViewFlipper>
You can see that we have defined a layout using the ViewFlipper. In the ViewFlipper we've included two views; our first view and our second view. Initially ViewFlipper will show our first child view. We haven't defined these child views yet so lets do that. First we need to create our first view. In the res/layout directory create a new file called first_view.xml. Now add this xml to the file:
========
SSH CLIENT...OPEN SOURCE
http://connectbot.googlecode.com/svn-hi ... ivity.java##################################
STOP ACTIVITIES RESTARTING...
http://www.anddev.org/viewtopic.php?p=31198Thanks for helping out. It figured it out, referring to the exact same site you pointed me to.
I just added a XML:
android:configChanges="orientation"
to my main Activity in the Android Manifest and overrode the onConfigurationChanged(Configuration newConfig) in the corresponding Activity like this:
Java:
@Override
public void onConfigurationChanged(Configuration newConfig) {
// TODO Auto-generated method stub
super.onConfigurationChanged(newConfig);
}
Works neatly.
Awesome
##################################
MORE ORIENTATION ACTIVITY RESTARTING ISSUE
This one…
http://www.anddev.org/viewtopic.php?p=31198http://stackoverflow.com/questions/5847 ... ose-valuesALSO…
You can rotate the emulator via…CTRL+F12…
Make use of LOG.d statement for the logcat ADB debugs…
read this for orientation locking…under the screen orientation.
http://android-developers.blogspot.com/ ... -apps.htmlthis may be some..
http://www.anddev.org/viewtopic.php?p=13371MAY BE SOLUTION
http://www.anddev.org/detect_if_orienta ... t8689.html########################################==========
Test Tabs and activities here with out a map…
http://www.androidsnippets.org/snippets/68/====================
adding tabs on a click of a button
TAB BACKGROUND AS WELL
http://www.coderanch.com/t/444206/Andro ... -one-afterChanging Check Box background
http://www.designerandroid.com/?cat=3=========
dynamic tabs… maybe
http://www.androidguys.com/2008/08/12/a ... namically/http://www.anddev.org/solvedactivity_wi ... t9405.htmlTHIS ONE
http://whyandroid.com/android/162-addin ... cally.html=======
2tabs with browser activities.
http://www.androidguys.com/2008/12/05/t ... h-intents/================
Tab with activity to refresh activity
http://groups.google.com/group/android- ... 84bbee2040==
CUSTOM AND NICE TABS
http://devtcg.blogspot.com/2008/03/adva ... -demo.html===
NICE TAB…THIS ONE SEE..
http://wshaban.blogspot.com/2008/04/cre ... noird.html==========
using
[syntax="java"]
ts1.setIndicator("Using Current Location");
ts1.setContent(new TabHost.TabContentFactory(){
public View createTabContent(String tag)
{
MapView mv=(MapView)AddNewLocationBookmark.this.findViewById(R.id.current_location_map);
return mv;
}
});
now it works
===========
This one
http://www.anddev.org/viewtopic.php?p=31151http://vkroz.wordpress.com/2009/07/03/p ... -tab-view/tabs/maps….and icons in tabs
http://osdir.com/ml/handhelds.android.d ... 00161.htmlGPS user trackerhttp://www.calvin.edu/~jpr5/android/tracker.html###################################################################
Preferences Savinghttp://thedevelopersinfo.com/2009/11/19 ... n-android/File System
http://thedevelopersinfo.com/2009/11/26 ... n-android/Image Savings
http://thedevelopersinfo.com/2009/12/18 ... n-android/Boot up start applicationshttp://thedevelopersinfo.com/2009/12/18 ... n-android/Hiding the title barhttp://thedevelopersinfo.com/2009/10/16 ... n-android/Email sending in Android
http://thedevelopersinfo.com/2009/10/22 ... n-android/--------
IMAGESVIEW
GALLERYhttp://mobiforge.com/designing/story/un ... more-viewsSET RINGTONE IN CODEhttp://stackoverflow.com/questions/1271 ... y-activityhttp://stackoverflow.com/questions/6232 ... ngs-screenVOLUMEhttp://stackoverflow.com/questions/6286 ... ndroid-app==================
SoundPoolhttp://www.anddev.org/using_soundpool_i ... t3115.htmlhttp://groups.google.com/group/android- ... 7537&pli=1MAP AND MORE FEATUREShttp://www.anddev.org/viewtopic.php?p=20172How to take picture in your codehttp://www.brighthub.com/mobile/google- ... 43414.aspxCustomzing TABShttp://tholix.com/blog/2009/01/customiz ... icons.htmlTO KNOW
UNDOCUMENTED BUTTON IMAGESbutton background image streatch
http://www.anddev.org/tutorial_buttons_ ... t4369.htmlBACKGROUND ORIENTATION CHANGE.also handling rotation events and handging on to data
http://groups.google.com/group/android- ... 2a01bdfde5Put the portrait one in res/layout. Put the landscape one in
res/layout-land. Name them both the same (e.g., main.xml).
And, *poof*, it works.
I have three recent blog posts up on AndroidGuys, covering how to handle
rotation events. Here's the third, which has links to the first two:
http://androidguys.com/?p=2723 Timeout screen lock code
http://stackoverflow.com/questions/5766 ... -idle-time======================
SOUNDPOOL CLASS
###################################################################################
Yeah there's something you need to know about SoundPool: Init well
before playing - that is, you need to know way ahead of time what
sounds you will be using because it doesn't work well to play
immediately after initializing. I think they attempt to initialize
asynchronously or something because I had problems when I tried to
load and play back to back like you're trying there.
When I use SoundPool, I load everything upon creation of the instance
of the game then trigger the plays whenever I need them. Here's my
current code for SoundPoolSoundManager:
public class SoundPoolSoundManager implements SoundManager {
private static final String TAG = "SoundPoolSoundManager";
public static final int SOUND_1 = 1;
private boolean enabled = true;
private Context context;
private SoundPool soundPool;
private HashMap<Integer, Integer> soundPoolMap;
public SoundPoolSoundManager(Context context) {
this.context = context;
}
public void reInit() {
init();
}
public void init() {
if (enabled) {
Log.d(TAG, "Initializing new SoundPool");
//re-init sound pool to work around bugs
release();
soundPool = new SoundPool(SOUNDPOOL_STREAMS,
AudioManager.STREAM_MUSIC, 100);
soundPoolMap = new HashMap<Integer, Integer>();
soundPoolMap.put(SOUND_1, soundPool.load(context, R.raw.sound1,
1));
Log.d(TAG, "SoundPool initialized");
}
}
public void release() {
if (soundPool != null) {
Log.d(TAG, "Closing SoundPool");
soundPool.release();
soundPool = null;
Log.d(TAG, "SoundPool closed");
return;
}
}
public void playSound(int sound) {
if (soundPool != null) {
Log.d(TAG, "Playing Sound " + sound);
AudioManager mgr = (AudioManager)
context.getSystemService(Context.AUDIO_SERVICE);
int streamVolume = mgr.getStreamVolume(AudioManager.STREAM_MUSIC);
Integer soundId = soundPoolMap.get(sound);
if (soundId != null) {
soundPool.play(soundPoolMap.get(sound), streamVolume,
streamVolume, 1, 0, 1f);
}
}
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
}
###################################################################################
SET VOLUME HIGH
VOLUME SETTING SLIDER
AUDIO MANAGER
http://code.google.com/p/app-soundmanag ... olume.javaTHE WHOLE PROJECT
http://code.google.com/p/app-soundmanag ... #trunk/res----------------
SMSPOPUPhttp://code.google.com/p/android-smspop ... ce/browse/screen shots
http://code.google.com/p/android-smspopup/-------------------
To set a message usig BUILDER....see line 429-430
http://code.google.com/p/app-soundmanag ... tings.javaPREFERENCESThe code you need for TAB2
http://thedevelopersinfo.com/2009/11/25 ... n-android/http://stackoverflow.com/questions/5314 ... erence-sumhttp://www.androidcompetencycenter.com/ ... eferences/TEST PREF
http://www.androidsnippets.org/snippets/34/################################################
################################################
I need to set the volume high before I sound the siren
Adjusting Audio Manager
http://www.anddev.org/viewtopic.php?p=31831=================================================================
Google Map Navigations
http://www.anddev.org/viewtopic.php?p=26435SATELLITE VIEW
http://www.anddev.org/viewtopic.php?p=28954--
Code:
myMapView = (MapView) findViewById(R.id.myGMap);
geoPoint = new GeoPoint((int) (latitude * 1000000), (int) (longitude * 1000000));
myMapView.setSatellite(false);
Sample MAP ACTIVITY...
the link above..download the code...
---
CAPTURE CURRENT LOCATION BY CLICK...LONGTITUTE AND LADITUTE
http://www.anddev.org/viewtopic.php?p=28140also see
http://www.anddev.org/viewtopic.php?p=24007FRIEND FINDER CODE
http://www.anddev.org/the_friend_finder ... i-t93.html======================================
CRAZY LONG LOGIN SCREEN PROCESS
http://www.anddev.org/viewtopic.php?p=20994---------------------
Using ProgressDialog in Android Activity
http://thedevelopersinfo.com/2009/10/16 ... -activity/and
Using Handler for long-time operations in Android
http://thedevelopersinfo.com/2009/10/19 ... n-android/more...
PROGRESS SHOW AND DISMISS
myProgressDialog = ProgressDialog.show(YOURCLASSNAME.this,
"Please wait...", "Doing Extreme Calculations...", true);
then...after done operation...call
myProgressDialog.dismiss();
CELLID
http://www.anddev.org/poor_mans_gps_-_c ... -t257.html=============================
KEYGUARD LOCK
http://www.androidsoftwaredeveloper.com ... -keyguard/see the managekeyguard link
here see the enable and disable methods
http://www.google.com/codesearch/p?hl=e ... d-smspopup\.googlecode\.com
=========================
RADAR RADAR RADAR###############
http://code.google.com/p/apps-for-andro ... runk/Radarhttp://www.anddev.org/panoramio_and_rad ... t2920.htmlneed entry in main.xml
http://code.google.com/p/apps-for-andro ... /radar.xmlpeople who implemented RADAR
http://groups.google.com/group/android- ... ba87263bb5--------------------------
MAP WITH PHOTOES OF ALL OVER THE WORLD
http://www.panoramio.com/COOL WATCH PHONE
http://www.coolest-gadgets.com/page/46/==============
I THINK BEST PREFERENCE EXAMPLE
http://www.old.kaloer.com/android-preferences/==============
LANDSCAPE TO PORTRAIT background image change
customize background image based on device..
http://stackoverflow.co====================
How to send the coords of a location via URL from the phone….
In MAP code, get the lat+long
Then append them like this…
http://maps.google.com/maps?q=40.148143 ... 5588378906 between the lat and long append "+" in the middle
TRICK
How to get the coordinates (lat and long) from the browser in Maps.google.com
1) first find the location via address using google maps
2) then once the location is found and your location is in the center,
3) paste this code in the browser address bar and enter… (---> javascript:void(prompt('',gApplication.getMap().getCenter())); <-----)
source
http://www.tech-recipes.com/rx/2403/goo ... de_values/=================================
Keyguard lock
http://www.androidsnippets.org/snippets/43/THIS IS ALL THE LITTLE THINGS NEEDED
http://www.androidsnippets.org/Get the phone's LAST KNOWN LOCATION
http://www.androidsnippets.org/snippets/21/POWER MANAGER
http://www.anddev.org/viewtopic.php?p=32873==============================
CELLID.JAVA
http://www.devx.com/wireless/Article/40524/0/page/1BEST BEST CELL ID
ERRICSON CELLID TUTORIALS
https://labs.ericsson.com/apis/mobile-l ... on-androidhttps://labs.ericsson.com/apis/mobile-l ... umentation-----------------
Image Gallery
http://www.androidsnippets.org/snippets/25/...and
http://android-er.blogspot.com/2009/08/ ... idget.html...and
Tutorial:Camera and Gallery Demo
http://2009.hfoss.org/Tutorial:Camera_and_Gallery_Demohttp://2009.hfoss.org/Tutorial:Camera/Gallery_Part_II...and
http://androidsamples.blogspot.com/2009 ... mages.htmlOverlaying images...Transparent images
http://stackoverflow.com/questions/9619 ... in-android--------------
BASIC SMS SENDING
This one
http://mobiforge.com/developing/story/s ... ng-androidthen
...
http://stackoverflow.com/questions/9689 ... ry-messageThis sample shows how to send an SMS message to a mobile phone.
...
public void SmsMessageSend()
{
SmsMessage smsMessage = new SmsMessage();
//Set the message body and recipient.
smsMessage.Body = "Would you like to meet for lunch?";
smsMessage.To.Add(new Recipient("John Doe", "2065550199"));
smsMessage.RequestDeliveryReport = true;
//Send the SMS message.
smsMessage.Send();
return;
}
**********************
..
sms
http://thinkandroid.wordpress.com/2010/ ... plication/--
SmsManager sm = SmsManager.getDefault();
// here is where the destination of the text should go
String number = "6508570720";
sm.sendTextMessage(number, null, "Test SMS Message", null, null);
Need manifest permission
<uses-permission android:name="android.permission.SEND_SMS"></uses-permission>
--------------------------
JAVA MAIL - ADNROID MAIL
download these jars first
http://code.google.com/p/javamail-andro ... loads/list*******************************************
Nice Java Mail tutorial
Small Email program code
http://www.builderau.com.au/program/jav ... 936,00.htmSending Email on Android by SMTP (Gmail) Example Class
http://snipplr.com/view/16644/sending-e ... ple-class/Java Mail sending mail
http://stackoverflow.com/questions/2020 ... ndroid-app...
http://groups.google.com/group/android- ... a1b6957a9#THIS
http://davanum.wordpress.com/2007/12/22 ... -via-smtp/Good mail SMTP
http://k9mail.googlecode.com/issues/att ... sport.java-----
CELLID
WOW--- CELL ID WITH MANY INFORMATION EXTRACTED.
http://gears.googlecode.com/svn/trunk/g ... vider.javaGOOD CELLID
http://svn2.assembla.com/svn/AndroidLoc ... ation.javaCELL ID..ANOTHER ONE
http://davanum.wordpress.com/2007/12/01 ... cellidlac/GOOD CELL ID
http://mobiforge.com/developing/story/a ... ing-cellid--------
How to get all 6 neighborhood cell ids on Android
6 Cellids
http://stackoverflow.com/questions/1693 ... on-android##################################################################################################################################
WATCH OUT THIS ONLY WORKS WITH ERICSON PHONES
ERICSON CELLID 3.9Mil Unique Ids.
package com.ericsson;
------------------
MobileLocationDemoActivity.java
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.telephony.gsm.GsmCellLocation;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
public class MobileLocationDemoActivity extends Activity {
private final static String API_KEY = "INSERT KEY HERE";
private TelephonyManager tm;
private GsmCellLocation location;
private int cid, lac, mcc, mnc, cellPadding;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
/*
* Setup a listener for the UpdateCellButton. Pressing this button will fetch
* the current cell info from the phone.
*/
final Button UpdateCellButton = (Button) findViewById(R.id.UpdateCellButton);
UpdateCellButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
location = (GsmCellLocation) tm.getCellLocation();
cid = location.getCid();
lac = location.getLac();
/*
* Mcc and mnc is concatenated in the networkOperatorString. The first 3
* chars is the mcc and the last 2 is the mnc.
*/
String networkOperator = tm.getNetworkOperator();
if (networkOperator != null && networkOperator.length() > 0) {
try {
mcc = Integer.parseInt(networkOperator.substring(0, 3));
mnc = Integer.parseInt(networkOperator.substring(3));
} catch (NumberFormatException e) {
}
}
/*
* Check if the current cell is a UMTS (3G) cell. If a 3G cell the cell id
* padding will be 8 numbers, if not 4 numbers.
*/
if (tm.getNetworkType() == TelephonyManager.NETWORK_TYPE_UMTS) {
cellPadding = 8;
} else {
cellPadding = 4;
}
/*
* Update the GUI with the current cell's info
*/
((TextView) findViewById(R.id.TextView01)).setText("CellID: "
+ getPaddedHex(cid, cellPadding));
((TextView) findViewById(R.id.TextView02)).setText("Lac: "
+ getPaddedHex(lac, 4));
((TextView) findViewById(R.id.TextView03)).setText("Mcc: "
+ getPaddedInt(mcc, 3));
((TextView) findViewById(R.id.TextView04)).setText("Mnc: "
+ getPaddedInt(mnc, 2));
}
});
/*
* Setup a listener for the GetPositionButton. When pressing this button the
* cell info is sent to the server and hopefully we will get a longitude and
* latitude back.
*/
final Button GetPositionButton = (Button) findViewById(R.id.GetPositionButton);
GetPositionButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
String strResult;
/**
* Seems that cid and lac shall be in hex. Cid should be padded with zero's
* to 8 numbers if UMTS (3G) cell, otherwise to 4 numbers. Mcc padded to 3
* numbers. Mnc padded to 2 numbers.
*/
try {
// Update the current location
updateLocation(getPaddedHex(cid, cellPadding), getPaddedHex(lac, 4),
getPaddedInt(mnc, 2), getPaddedInt(mcc, 3));
strResult = "Position updated!";
} catch (IOException e) {
strResult = "Error!\n" + e.getMessage();
}
// Show an info Toast with the results of the updateLocation
// call.
Toast t = Toast.makeText(getApplicationContext(), strResult,
Toast.LENGTH_LONG);
t.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
t.show();
}
});
}
/**
* Convert an int to an hex String and pad with 0's up to minLen.
*/
String getPaddedHex(int nr, int minLen) {
String str = Integer.toHexString(nr);
if (str != null) {
while (str.length() < minLen) {
str = "0" + str;
}
}
return str;
}
/**
* Convert an int to String and pad with 0's up to minLen.
*/
String getPaddedInt(int nr, int minLen) {
String str = Integer.toString(nr);
if (str != null) {
while (str.length() < minLen) {
str = "0" + str;
}
}
return str;
}
/**
*
*/
private void updateLocation(String cid, String lac, String mnc, String mcc)
throws IOException {
InputStream is = null;
ByteArrayOutputStream bos = null;
byte[] data = null;
try {
// Build the url
StringBuilder uri = new StringBuilder("http://cellid.labs.ericsson.net/");
// Set this param to xml to get the server response in XML instead
// of json
uri.append("json");
uri.append("/lookup?cellid=").append(cid);
uri.append("&mnc=").append(mnc);
uri.append("&mcc=").append(mcc);
uri.append("&lac=").append(lac);
uri.append("&key=").append(API_KEY);
// Create an HttpGet request
HttpGet request = new HttpGet(uri.toString());
// Send the HttpGet request
HttpClient httpClient = new DefaultHttpClient();
HttpResponse response = httpClient.execute(request);
// Check the response status
int status = response.getStatusLine().getStatusCode();
if (status != HttpURLConnection.HTTP_OK) {
switch (status) {
case HttpURLConnection.HTTP_NO_CONTENT:
throw new IOException("The cell could not be " + "found in the database");
case HttpURLConnection.HTTP_BAD_REQUEST:
throw new IOException("Check if some parameter "
+ "is missing or misspelled");
case HttpURLConnection.HTTP_UNAUTHORIZED:
throw new IOException("Make sure the API key is " + "present and valid");
case HttpURLConnection.HTTP_FORBIDDEN:
throw new IOException("You have reached the limit"
+ "for the number of requests per day. The "
+ "maximum number of requests per day is " + "currently 500.");
case HttpURLConnection.HTTP_NOT_FOUND:
throw new IOException("The cell could not be found" + "in the database");
default:
throw new IOException("HTTP response code: " + status);
}
}
// The response was ok (HTTP_OK) so lets read the data
HttpEntity entity = response.getEntity();
is = entity.getContent();
bos = new ByteArrayOutputStream();
byte buf[] = new byte[256];
while (true) {
int rd = is.read(buf, 0, 256);
if (rd == -1)
break;
bos.write(buf, 0, rd);
}
bos.flush();
data = bos.toByteArray();
if (data != null) {
try {
// Parse the Json data
JSONObject position = new JSONObject(new String(data))
.getJSONObject("position");
// update the GUI items with the received position info
((TextView) findViewById(R.id.position_longitude)).setText("Longitude: "
+ position.getDouble("longitude"));
((TextView) findViewById(R.id.position_latitude)).setText("Latitude: "
+ position.getDouble("latitude"));
((TextView) findViewById(R.id.position_name)).setText("Name: "
+ position.getString("name"));
((TextView) findViewById(R.id.position_accuracy)).setText("Accuracy: "
+ position.getDouble("accuracy"));
} catch (JSONException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
} catch (MalformedURLException e) {
Log.e("ERROR", e.getMessage());
} catch (IllegalArgumentException e) {
throw new IOException(
"URL was incorrect. Did you forget to set the API_KEY?");
} finally {
// make sure we clean up after us
try {
if (bos != null)
bos.close();
} catch (Exception e) {
}
try {
if (is != null)
is.close();
} catch (Exception e) {
}
}
}
}
-------------------
layout/main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:text="CellID: " android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView android:text="Lac: " android:id="@+id/TextView02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView android:text="Mcc: " android:id="@+id/TextView03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView android:text="Mnc: " android:id="@+id/TextView04"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<Button android:text="Update cell" android:id="@+id/UpdateCellButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<TextView android:text="Latitude: " android:id="@+id/position_latitude"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView android:text="Longitude: " android:id="@+id/position_longitude"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView android:text="Name: " android:id="@+id/position_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView android:text="Accuracy: " android:id="@+id/position_accuracy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<Button android:text="Get position" android:id="@+id/GetPositionButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
----------------------------------
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ericsson"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true">
<activity android:name=".MobileLocationDemoActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="3" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
</manifest>
--------------------------------
###################################################################################################################
LinuxJournal intro to Android
http://www.linuxjournal.com/article/10453#####################################################################################
JAVA SMTP MAIL
http://k9mail.googlecode.com/issues/att ... sport.java--
package com.android.email.mail.transport;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketAddress;
import java.net.URI;
import java.net.URISyntaxException;
import java.security.GeneralSecurityException;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.List;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.SSLException;
import android.util.Config;
import android.util.Log;
import com.android.email.Email;
import com.android.email.PeekableInputStream;
import com.android.email.codec.binary.Base64;
import com.android.email.mail.Address;
import com.android.email.mail.AuthenticationFailedException;
import com.android.email.mail.Message;
import com.android.email.mail.MessagingException;
import com.android.email.mail.Store;
import com.android.email.mail.Transport;
import com.android.email.mail.CertificateValidationException;
import com.android.email.mail.Message.RecipientType;
import com.android.email.mail.store.TrustManagerFactory;
public class SmtpTransport extends Transport {
public static final int CONNECTION_SECURITY_NONE = 0;
public static final int CONNECTION_SECURITY_TLS_OPTIONAL = 1;
public static final int CONNECTION_SECURITY_TLS_REQUIRED = 2;
public static final int CONNECTION_SECURITY_SSL_REQUIRED = 3;
public static final int CONNECTION_SECURITY_SSL_OPTIONAL = 4;
String mHost;
int mPort;
String mUsername;
String mPassword;
int mConnectionSecurity;
boolean mSecure;
Socket mSocket;
PeekableInputStream mIn;
OutputStream mOut;
/**
*
smtp://user:password@server:port CONNECTION_SECURITY_NONE
*
smtp+tls://user:password@server:port CONNECTION_SECURITY_TLS_OPTIONAL
*
smtp+tls+://user:password@server:port CONNECTION_SECURITY_TLS_REQUIRED
*
smtp+ssl+://user:password@server:port CONNECTION_SECURITY_SSL_REQUIRED
*
smtp+ssl://user:password@server:port CONNECTION_SECURITY_SSL_OPTIONAL
*
* @param _uri
*/
public SmtpTransport(String _uri) throws MessagingException {
URI uri;
try {
uri = new URI(_uri);
} catch (URISyntaxException use) {
throw new MessagingException("Invalid SmtpTransport URI", use);
}
String scheme = uri.getScheme();
if (scheme.equals("smtp")) {
mConnectionSecurity = CONNECTION_SECURITY_NONE;
mPort = 25;
} else if (scheme.equals("smtp+tls")) {
mConnectionSecurity = CONNECTION_SECURITY_TLS_OPTIONAL;
mPort = 25;
} else if (scheme.equals("smtp+tls+")) {
mConnectionSecurity = CONNECTION_SECURITY_TLS_REQUIRED;
mPort = 25;
} else if (scheme.equals("smtp+ssl+")) {
mConnectionSecurity = CONNECTION_SECURITY_SSL_REQUIRED;
mPort = 465;
} else if (scheme.equals("smtp+ssl")) {
mConnectionSecurity = CONNECTION_SECURITY_SSL_OPTIONAL;
mPort = 465;
} else {
throw new MessagingException("Unsupported protocol");
}
mHost = uri.getHost();
if (uri.getPort() != -1) {
mPort = uri.getPort();
}
if (uri.getUserInfo() != null) {
String[] userInfoParts = uri.getUserInfo().split(":", 2);
mUsername = userInfoParts[0];
if (userInfoParts.length > 1) {
mPassword = userInfoParts[1];
}
}
}
public void open() throws MessagingException {
try {
SocketAddress socketAddress = new InetSocketAddress(mHost, mPort);
if (mConnectionSecurity == CONNECTION_SECURITY_SSL_REQUIRED ||
mConnectionSecurity == CONNECTION_SECURITY_SSL_OPTIONAL) {
SSLContext sslContext = SSLContext.getInstance("TLS");
boolean secure = mConnectionSecurity == CONNECTION_SECURITY_SSL_REQUIRED;
sslContext.init(null, new TrustManager[] {
TrustManagerFactory.get(mHost, secure)
}, new SecureRandom());
mSocket = sslContext.getSocketFactory().createSocket();
mSocket.connect(socketAddress, SOCKET_CONNECT_TIMEOUT);
mSecure = true;
} else {
mSocket = new Socket();
mSocket.connect(socketAddress, SOCKET_CONNECT_TIMEOUT);
}
// RFC 1047
mSocket.setSoTimeout(SOCKET_READ_TIMEOUT);
mIn = new PeekableInputStream(new BufferedInputStream(mSocket.getInputStream(), 1024));
mOut = mSocket.getOutputStream();
// Eat the banner
executeSimpleCommand(null);
String localHost = "localhost.localdomain";
try {
InetAddress localAddress = InetAddress.getLocalHost();
if (! localAddress.isLoopbackAddress()) {
// The loopback address will resolve to 'localhost'
// some mail servers only accept qualified hostnames, so make sure
// never to override "localhost.localdomain" with "localhost"
// TODO - this is a hack. but a better hack than what was there before
localHost = localAddress.getHostName();
}
} catch (Exception e) {
if (Config.LOGD) {
if (Email.DEBUG) {
Log.d(Email.LOG_TAG, "Unable to look up localhost");
}
}
}
List<String> results = executeSimpleCommand("EHLO " + localHost);
/*
* TODO may need to add code to fall back to HELO I switched it from
* using HELO on non STARTTLS connections because of AOL's mail
* server. It won't let you use AUTH without EHLO.
* We should really be paying more attention to the capabilities
* and only attempting auth if it's available, and warning the user
* if not.
*/
if (mConnectionSecurity == CONNECTION_SECURITY_TLS_OPTIONAL
|| mConnectionSecurity == CONNECTION_SECURITY_TLS_REQUIRED) {
if (results.contains("STARTTLS")) {
executeSimpleCommand("STARTTLS");
SSLContext sslContext = SSLContext.getInstance("TLS");
boolean secure = mConnectionSecurity == CONNECTION_SECURITY_TLS_REQUIRED;
sslContext.init(null, new TrustManager[] {
TrustManagerFactory.get(mHost, secure)
}, new SecureRandom());
mSocket = sslContext.getSocketFactory().createSocket(mSocket, mHost, mPort,
true);
mIn = new PeekableInputStream(new BufferedInputStream(mSocket.getInputStream(),
1024));
mOut = mSocket.getOutputStream();
mSecure = true;
/*
* Now resend the EHLO. Required by RFC2487 Sec. 5.2, and more specifically,
* Exim.
*/
results = executeSimpleCommand("EHLO " + localHost);
} else if (mConnectionSecurity == CONNECTION_SECURITY_TLS_REQUIRED) {
throw new MessagingException("TLS not supported but required");
}
}
/*
* result contains the results of the EHLO in concatenated form
*/
boolean authLoginSupported = false;
boolean authPlainSupported = false;
for (String result : results)
{
if (result.matches(".*AUTH.*LOGIN.*$") == true)
{
authLoginSupported = true;
}
if (result.matches(".*AUTH.*PLAIN.*$") == true)
{
authPlainSupported = true;
}
}
if (mUsername != null && mUsername.length() > 0 && mPassword != null
&& mPassword.length() > 0) {
if (authPlainSupported) {
saslAuthPlain(mUsername, mPassword);
}
else if (authLoginSupported) {
saslAuthLogin(mUsername, mPassword);
}
else {
throw new MessagingException("No valid authentication mechanism found.");
}
}
} catch (SSLException e) {
throw new CertificateValidationException(e.getMessage(), e);
} catch (GeneralSecurityException gse) {
throw new MessagingException(
"Unable to open connection to SMTP server due to security error.", gse);
} catch (IOException ioe) {
throw new MessagingException("Unable to open connection to SMTP server.", ioe);
}
}
public void sendMessage(Message message) throws MessagingException {
close();
open();
Address[] from = message.getFrom();
boolean possibleSend = false;
try {
executeSimpleCommand("MAIL FROM: " + "<" + from[0].getAddress() + ">");
for (Address address : message.getRecipients(RecipientType.TO)) {
executeSimpleCommand("RCPT TO: " + "<" + address.getAddress() + ">");
}
for (Address address : message.getRecipients(RecipientType.CC)) {
executeSimpleCommand("RCPT TO: " + "<" + address.getAddress() + ">");
}
for (Address address : message.getRecipients(RecipientType.BCC)) {
executeSimpleCommand("RCPT TO: " + "<" + address.getAddress() + ">");
}
message.setRecipients(RecipientType.BCC, null);
executeSimpleCommand("DATA");
// TODO byte stuffing
message.writeTo(
new EOLConvertingOutputStream(
new BufferedOutputStream(mOut, 1024)));
possibleSend = true; // After the "\r\n." is attempted, we may have sent the message
executeSimpleCommand("\r\n.");
} catch (Exception e) {
MessagingException me = new MessagingException("Unable to send message", e);
me.setPermanentFailure(possibleSend);
throw me;
}
finally
{
close();
}
}
public void close() {
try {
mIn.close();
} catch (Exception e) {
}
try {
mOut.close();
} catch (Exception e) {
}
try {
mSocket.close();
} catch (Exception e) {
}
mIn = null;
mOut = null;
mSocket = null;
}
private String readLine() throws IOException {
StringBuffer sb = new StringBuffer();
int d;
while ((d = mIn.read()) != -1) {
if (((char)d) == '\r') {
continue;
} else if (((char)d) == '\n') {
break;
} else {
sb.append((char)d);
}
}
String ret = sb.toString();
if (Email.DEBUG) {
Log.d(Email.LOG_TAG, "SMTP <<< " + ret);
}
return ret;
}
private void writeLine(String s) throws IOException {
if (Email.DEBUG) {
Log.d(Email.LOG_TAG, "SMTP >>> " + s);
}
mOut.write(s.getBytes());
mOut.write('\r');
mOut.write('\n');
mOut.flush();
}
private void checkLine(String line) throws MessagingException
{
if (line.length() < 1)
{
throw new MessagingException("SMTP response is 0 length");
}
char c = line.charAt(0);
if ((c == '4') || (c == '5')) {
throw new MessagingException(line);
}
}
private List<String> executeSimpleCommand(String command) throws IOException, MessagingException {
List<String> results = new ArrayList<String>();
if (command != null) {
writeLine(command);
}
boolean cont = false;
do
{
String line = readLine();
checkLine(line);
if (line.length() >= 4)
{
results.add(line);
if (line.charAt(3) == '-')
{
cont = true;
}
else
{
cont = false;
}
}
} while (cont);
return results;
}
// C: AUTH LOGIN
// S: 334 VXNlcm5hbWU6
// C: d2VsZG9u
// S: 334 UGFzc3dvcmQ6
// C: dzNsZDBu
// S: 235 2.0.0 OK Authenticated
//
// Lines 2-5 of the conversation contain base64-encoded information. The same conversation, with base64 strings decoded, reads:
//
//
// C: AUTH LOGIN
// S: 334 Username:
// C: weldon
// S: 334 Password:
// C: w3ld0n
// S: 235 2.0.0 OK Authenticated
private void saslAuthLogin(String username, String password) throws MessagingException,
AuthenticationFailedException, IOException {
try {
executeSimpleCommand("AUTH LOGIN");
executeSimpleCommand(new String(Base64.encodeBase64(username.getBytes())));
executeSimpleCommand(new String(Base64.encodeBase64(password.getBytes())));
}
catch (MessagingException me) {
if (me.getMessage().length() > 1 && me.getMessage().charAt(1) == '3') {
throw new AuthenticationFailedException("AUTH LOGIN failed (" + me.getMessage()
+ ")");
}
throw me;
}
}
private void saslAuthPlain(String username, String password) throws MessagingException,
AuthenticationFailedException, IOException {
byte[] data = ("\000" + username + "\000" + password).getBytes();
data = new Base64().encode(data);
try {
executeSimpleCommand("AUTH PLAIN " + new String(data));
}
catch (MessagingException me) {
if (me.getMessage().length() > 1 && me.getMessage().charAt(1) == '3') {
throw new AuthenticationFailedException("AUTH PLAIN failed (" + me.getMessage()
+ ")");
}
throw me;
}
}
}
###################################################################
SEND NOTIFICATION FROM A SERVICE
http://stackoverflow.com/questions/1207 ... in-android=========================
There are only 10 types of people in the world...
Those who know binary and those who don't.
###############################################
http://www.anddev.org/viewtopic.php?p=26603Camera Image Capture...GOOOOOOOOOOOD
...
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.net.Uri;
import android.os.Handler;
import android.os.Message;
import android.os.Bundle;
import android.provider.MediaStore.Images;
import android.provider.MediaStore.Video;
import android.view.Menu;
import android.view.MenuItem;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.KeyEvent;
import android.view.Window;
import android.hardware.Camera;
import android.hardware.Camera.PictureCallback;
import android.hardware.Camera.ShutterCallback;
import android.util.Log;
public class CameraApiTest extends Activity implements SurfaceHolder.Callback
{
private static final String TAG = "CameraApiTest";
Camera mCamera;
boolean mPreviewRunning = false;
Context context;
public void onCreate(Bundle icicle)
{
super.onCreate(icicle);
requestWindowFeature(Window.FEATURE_NO_TITLE);
Log.e(TAG, "onCreate");
getWindow().setFormat(PixelFormat.TRANSLUCENT);
setContentView(R.layout.camera_api_test);
mSurfaceView = (SurfaceView)findViewById(R.id.surface);
mSurfaceHolder = mSurfaceView.getHolder();
mSurfaceHolder.addCallback(this);
mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
public boolean onCreateOptionsMenu(android.view.Menu menu) {
MenuItem item = menu.add(0, 0, 0, "goto gallery");
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
Uri target = Uri.parse("content://media/external/images/media");
Intent intent = new Intent(Intent.ACTION_VIEW, target);
startActivity(intent);
return true;
}
});
return true;
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState)
{
super.onRestoreInstanceState(savedInstanceState);
}
Camera.PictureCallback mPictureCallback = new Camera.PictureCallback() {
public void onPictureTaken(byte[] data, Camera c) {
Log.e(TAG, "PICTURE CALLBACK: data.length = " + data.length);
mCamera.startPreview();
}
};
public boolean onKeyDown(int keyCode, KeyEvent event)
{
if (keyCode == KeyEvent.KEYCODE_BACK) {
return super.onKeyDown(keyCode, event);
}
if (keyCode == KeyEvent.KEYCODE_SPACE) {
mCamera.takePicture(shutterCallback, rawCallback,mPictureCallback);
return true;
}
return false;
}
ShutterCallback shutterCallback = new ShutterCallback() {
public void onShutter() {
// TODO Do something when the shutter closes.
}
};
PictureCallback rawCallback = new PictureCallback() {
public void onPictureTaken(byte[] _data, Camera _camera) {
// TODO Do something with the image RAW data.
}
};
protected void onResume()
{
Log.e(TAG, "onResume");
super.onResume();
}
protected void onSaveInstanceState(Bundle outState)
{
super.onSaveInstanceState(outState);
}
protected void onStop()
{
Log.e(TAG, "onStop");
super.onStop();
}
public void surfaceCreated(SurfaceHolder holder)
{
Log.e(TAG, "surfaceCreated");
mCamera = Camera.open();
//mCamera.startPreview();
}
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h)
{
Log.e(TAG, "surfaceChanged");
// XXX stopPreview() will crash if preview is not running
if (mPreviewRunning) {
mCamera.stopPreview();
}
Camera.Parameters p = mCamera.getParameters();
p.setPreviewSize(w, h);
mCamera.setParameters(p);
try{
mCamera.setPreviewDisplay(holder);
}catch(Exception e)
{
new AlertDialog.Builder(context).setTitle("Error")
.setMessage(e.getMessage())
.setPositiveButton("OK", null).show();
}
mCamera.startPreview();
mPreviewRunning = true;
}
public void surfaceDestroyed(SurfaceHolder holder)
{
Log.e(TAG, "surfaceDestroyed");
mCamera.stopPreview();
mPreviewRunning = false;
mCamera.release();
}
private SurfaceView mSurfaceView;
private SurfaceHolder mSurfaceHolder;
}
...........
SAVE CAMERA IMAGE
http://stackoverflow.com/questions/1910 ... ure-intent.....
private void saveFullImage() {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File file = new File(Environment.getExternalStorageDirectory(), "test.jpg");
outputFileUri = Uri.fromFile(file);
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
startActivityForResult(intent, TAKE_PICTURE);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if ((requestCode == TAKE_PICTURE) && (resultCode == Activity.RESULT_OK)) {
// Check if the result includes a thumbnail Bitmap
if (data == null) {
// TODO Do something with the full image stored
// in outputFileUri. Perhaps copying it to the app folder
}
}
}
................
CAMERA IMAGE CAPTURE...GOOD
http://stackoverflow.com/questions/1567 ... he-galleryGood Image capture
http://www.anddev.org/viewtopic.php?p=26603camera sdk1.1
http://www.anddev.org/tutorial_for_capt ... t6489.htmlwrite image on sdcard
http://www.coderanch.com/t/436286/Andro ... d-emulatorCamera
code
http://osdir.com/ml/AndroidDevelopers/2 ... 01824.htmlmore camera..MAY BE COMPLETE
http://stackoverflow.com/questions/9511 ... iew-widgetBEST CAMERA APP EVER##########################
http://github.com/commonsguy/cw-advandr ... ra/PictureTHIS CAMERA ONE IS ALSO GOOOOOOOOD
http://snippets.dzone.com/posts/show/8683###############################
Try THIS CAMERA FIRST
...
import java.io.IOException;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.PixelFormat;
import android.hardware.Camera;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
public class CamaraView extends Activity implements SurfaceHolder.Callback,
OnClickListener {
static final int FOTO_MODE = 0;
private static final String TAG = "CameraTest";
Camera mCamera;
boolean mPreviewRunning = false;
private Context mContext = this;
private String mExpNumber;
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
Log.e(TAG, "onCreate");
Bundle extras = getIntent().getExtras();
mExpNumber = extras.getString("EXP_NUMBER");
getWindow().setFormat(PixelFormat.TRANSLUCENT);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.camera);
mSurfaceView = (SurfaceView) findViewById(R.id.surface_camera);
mSurfaceView.setOnClickListener(this);
mSurfaceHolder = mSurfaceView.getHolder();
mSurfaceHolder.addCallback(this);
mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
}
Camera.PictureCallback mPictureCallback = new Camera.PictureCallback() {
public void onPictureTaken(byte[] imageData, Camera c) {
if (imageData != null) {
Intent mIntent = new Intent();
FileUtilities.StoreByteImage(mContext, imageData,
50, mExpNumber);
mCamera.startPreview();
setResult(FOTO_MODE,mIntent);
finish();
}
}
};
protected void onResume() {
Log.e(TAG, "onResume");
super.onResume();
}
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
}
protected void onStop() {
Log.e(TAG, "onStop");
super.onStop();
}
public void surfaceCreated(SurfaceHolder holder) {
Log.e(TAG, "surfaceCreated");
mCamera = Camera.open();
}
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
Log.e(TAG, "surfaceChanged");
// XXX stopPreview() will crash if preview is not running
if (mPreviewRunning) {
mCamera.stopPreview();
}
Camera.Parameters p = mCamera.getParameters();
p.setPreviewSize(w, h);
mCamera.setParameters(p);
try {
mCamera.setPreviewDisplay(holder);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
mCamera.startPreview();
mPreviewRunning = true;
}
public void surfaceDestroyed(SurfaceHolder holder) {
Log.e(TAG, "surfaceDestroyed");
mCamera.stopPreview();
mPreviewRunning = false;
mCamera.release();
}
private SurfaceView mSurfaceView;
private SurfaceHolder mSurfaceHolder;
public void onClick(View arg0) {
mCamera.takePicture(null, mPictureCallback, mPictureCallback);
}
}
---------
AndroidManifest.xml. T
<uses-permission android:name="android.permission.CAMERA"/>
http://www.brighthub.com/mobile/google- ... 4.aspx?p=2...
xml file for above
// This is the XML file to use in the Camera Activity
setContentView(R.layout.camera);
camera.xml
..
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical">
<SurfaceView android:id="@+id/surface_camera"
android:layout_width="fill_parent" android:layout_height="10dip"
android:layout_weight="1">
</SurfaceView>
</LinearLayout>
..............
CREATE THIS CODE IN A DIFFERENT CLASS FILE like FileUtilities called in the code above....
Store Image
// This code shows the way to store an image from a byte[] array.
public static boolean StoreByteImage(Context mContext, byte[] imageData,int quality, String expName) {
File sdImageMainDirectory = "/sdcard/myImages";
FileOutputStream fileOutputStream = null;
String nameFile;
try {
BitmapFactory.Options options=new BitmapFactory.Options();
options.inSampleSize = 5;
Bitmap myImage = BitmapFactory.decodeByteArray(imageData, 0,
imageData.length,options);
fileOutputStream = new FileOutputStream(
sdImageMainDirectory.toString() +"/" + nameFile + ".jpg");
BufferedOutputStream bos = new BufferedOutputStream(
fileOutputStream);
myImage.compress(CompressFormat.JPEG, quality, bos);
bos.flush();
bos.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return true;
}
###############################
SEND IMAGE AS MMS
http://www.brighthub.com/mobile/google- ... 2#commentsThanks a million for the quick response.
So see if I understand this correctly, here is what I am doing...
I am using your code...found here...
http://snippets.dzone.com/user/Jbeer1) CamaraView --- class
2) FileUtilities --- class with (storeByteImage) method.
in this storeByteImage method, image is saved as .jpg.
So now I am creating another method that is to send the MMS with the image like this.
//HE said need to enter the extra...to address etc...find how to send mms first.
public void sendMMS() {
String url = "/sdcard/myImages/myimage.jpg";
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("image/jpg");
sendIntent.putExtra(Intent.EXTRA_SUBJECT, “My Picture”);
sendIntent.putExtra("sms_body", "here put the body");
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(url));
}
??? What size image will your program save? so the SendMMS can send it properly.
---------
Also, for the GridView
I need my pictures to look like this...
http://developer.android.com/guide/tuto ... dview.htmlInstead of hardcoding the images, how can I read the images in a specific directory for this app.
Thanks alot again, I really appreciate it.
Yassin
----MMS
http://www.netmite.com/android/mydroid/ ... ivity.java$$$$$$$$$$$$$$$$$$$
MMS GOOD SITE SEE THIS ONE
http://jtribe.blogspot.com/2008/12/send ... droid.html#################################
=====================
AUDIO RECORDER
---------------------------------------------------------------------------------------------
http://www.benmccann.com/dev-blog/andro ... -tutorial/......
package com.benmccann.android.hello;
import java.io.File;
import java.io.IOException;
import android.media.MediaRecorder;
import android.os.Environment;
/**
* @author <a href="http://www.benmccann.com">Ben McCann</a>
*/
public class AudioRecorder {
final MediaRecorder recorder = new MediaRecorder();
final String path;
/**
* Creates a new audio recording at the given path (relative to root of SD card).
*/
public AudioRecorder(String path) {
this.path = sanitizePath(path);
}
private String sanitizePath(String path) {
if (!path.startsWith("/")) {
path = "/" + path;
}
if (!path.contains(".")) {
path += ".3gp";
}
return Environment.getExternalStorageDirectory().getAbsolutePath() + path;
}
/**
* Starts a new recording.
*/
public void start() throws IOException {
String state = android.os.Environment.getExternalStorageState();
if(!state.equals(android.os.Environment.MEDIA_MOUNTED)) {
throw new IOException("SD Card is not mounted. It is " + state + ".");
}
// make sure the directory we plan to store the recording in exists
File directory = new File(path).getParentFile();
if (!directory.exists() && !directory.mkdirs()) {
throw new IOException("Path to file could not be created.");
}
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setOutputFile(path);
recorder.prepare();
recorder.start();
}
/**
* Stops a recording that has been previously started.
*/
public void stop() throws IOException {
recorder.stop();
recorder.release();
}
}
AND
----------------
Hi, the cause is that the source above is not an android *application*, just a helper class. So it just can’t run by itself.
You have to do something like this:
public class MyActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final AudioRecorder recorder = new AudioRecorder(“/audiometer/temp”);
recorder.start();
//….wait a while
recorder.stop();
}
}
##########################################################
Not Android...
Useful collection of Web Links (Just for the technical head geeks)
http://www.swview.org/links