Diese Präsentation wurde erfolgreich gemeldet.
Die SlideShare-Präsentation wird heruntergeladen. ×

Share file to dropbox in android example

Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Nächste SlideShare
Arrangement de la mémoire
Arrangement de la mémoire
Wird geladen in …3
×

Hier ansehen

1 von 8 Anzeige
Anzeige

Weitere Verwandte Inhalte

Andere mochten auch (20)

Anzeige

Ähnlich wie Share file to dropbox in android example (20)

Aktuellste (20)

Anzeige

Share file to dropbox in android example

  1. 1.  JavatechIG.com Search   (http://javatechig.com/) Home (http://javatechig.com)  Android  (http://javatechig.com/category/android) Share file Dropbox in in Android Example Share file to to DropboxAndroid Example Java  (http://javatechig.com/category/java) More.. (http://javatechig.com/tutorials)  ANDROID (HTTP://JAVATECHIG.COM/CATEGORY/ANDROID) NEXT  Advertise (http://javatechig.com/advertise) BY NILANCHALA (HTTP://JAVATECHIG.COM/AUTHOR/NILANCHALA) / JANUARY 18, 2014  (JAVSCRIPT:VOID(0))  (MAILTO:JAVATECHIG@GMAIL.COM?SUBJECT=SHARE+FILE+TO+DROPBOX+IN+ANDROID+EXAMPLE) A+ A- In this example we will see how to use Dropbox API to share Share file to Dropbox in from your native Android application. Creating an app on Dropbox You can download Dropbox API (https://www.dropbox.com/developers/core/sdks/android) from official source. The downloaded Zip will have sample and library. The Dropbox SDK gives you a way to share files with a Dropbox account. Before integrating Dropbox SDK to your android app you have to create a new app on Dropbox developer console. Visit Dropbox developer console (https://www.dropbox.com/developers/apps) and create a new application. Once you create the application you will get an App key and App Secret. Android app using Dropbox SDK Now do the following changes to your application manifest file. Put the following code before </application> tag. Make sure you are using your own AppID obtained from Facebook developer console. 1 2 <ciiy atvt ? adodnm=cmdobxcin2adodAtAtvt" nri:ae"o.rpo.let.nri.uhciiy
  2. 2. 3 4 5 6 7 8 9 1 0 1 1 1 2 1 3 1 4 1 5 adodcniCags"retto|ebad nri:ofghne=oinainkyor" adodlucMd=snlTs"> nri:anhoe"igeak <netfle> itn-itr <- Cag ti t b d-floe b yu apky-> !- hne hs o e b olwd y or p e <aaadodshm=d-aqqblht"/ dt nri:cee"bytpy9s0u > <cinadodnm=adoditn.cinVE"/ ato nri:ae"nri.netato.IW > <aeoyadodnm=adoditn.aeoyBOSBE ctgr nri:ae"nri.netctgr.RWAL" <aeoyadodnm=adoditn.aeoyDFUT ctgr nri:ae"nri.netctgr.EAL" <itn-itr /netfle> <atvt> /ciiy Note: Make sure that you have give android.permission.INTERNET permission in your application manifest file. Your Activity Layout Now define layout for your activity class. In this example, We have three sample buttons one for login/logout , upload and view files. 1 2 3 4 5 6 7 8 9 1 0 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 2 0 2 1 2 2 2 3 2 4 2 5 2 6 2 7 2 8 2 9 ? <xlvrin"."ecdn=uf8? ?m eso=10 noig"t-"> <ieraotxlsadod"tp/shmsadodcmakrsadod LnaLyu mn:nri=ht:/cea.nri.o/p/e/nri adodlyu_it=mthprn" nri:aotwdh"ac_aet adodlyu_egt"ac_aet nri:aothih=mthprn" adodlyu_agno=2d" nri:aotmriTp"0p adodgaiy"etrhrzna" nri:rvt=cne_oiotl adodoinain"etcl > nri:retto=vria" <utn Bto adodi=@i/rpo_oi" nri:d"+ddobxlgn adodlyu_it=mthprn" nri:aotwdh"ac_aet adodlyu_egt"rpcnet nri:aothih=wa_otn" adodlyu_agn"0p nri:aotmri=1d" adodbcgon=#7CC nri:akrud"16E" adodtx=Lgnt Dobx nri:et"oi o rpo" adodtxApaac=?nri:trtxApaacLre nri:etperne"adodat/etperneag" adodtxClr"ff nri:etoo=#f" adodtxSye"od / nri:ettl=bl" > <utn Bto adodi=@i/podfl" nri:d"+dula_ie adodlyu_it=mthprn" nri:aotwdh"ac_aet adodlyu_egt"rpcnet nri:aothih=wa_otn" adodlyu_agn"0p nri:aotmri=1d" adodbcgon=#7CC nri:akrud"16E" adodtx=Ula Fl t Dobx nri:et"pod ie o rpo" adodtxApaac=?nri:trtxApaacLre nri:etperne"adodat/etperneag" adodtxClr"ff nri:etoo=#f" adodtxSye"od / nri:ettl=bl" >
  3. 3. 3 0 3 1 3 2 3 3 3 4 3 5 3 6 3 7 3 8 3 9 4 0 4 1 4 2 4 3 4 4 4 5 4 6 4 7 4 8 4 9 5 0 5 1 5 2 5 3 5 4 5 5 <utn Bto adodi=@i/itfls nri:d"+dls_ie" adodlyu_it=mthprn" nri:aotwdh"ac_aet adodlyu_egt"rpcnet nri:aothih=wa_otn" adodlyu_agn"0p nri:aotmri=1d" adodbcgon=#7CC nri:akrud"16E" adodtx=Ls AlFls nri:et"it l ie" adodtxApaac=?nri:trtxApaacLre nri:etperne"adodat/etperneag" adodtxClr"ff nri:etoo=#f" adodtxSye"od / nri:ettl=bl" > <coliw SrlVe adodlyu_it=fl_aet nri:aotwdh"ilprn" adodlyu_egt"ac_aet nri:aothih=mthprn" adodlyu_agn"0p > nri:aotmri=1d" <ieraot LnaLyu adodi=@i/otie_ie" nri:d"+dcnanrfls adodlyu_it=mthprn" nri:aotwdh"ac_aet adodlyu_egt"rpcnet nri:aothih=wa_otn" adodoinain"etcl > nri:retto=vria" <LnaLyu> /ieraot <SrlVe> /coliw <LnaLyu> /ieraot Activity Java class 1 2 3 4 5 6 7 8 9 1 0 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 2 0 2 1 2 2 2 3 2 4 pcaecmjvtci.rposml; akg o.aaehgdobxape ? ipr jv.tlAryit mot aaui.raLs; ipr adodapAtvt; mot nri.p.ciiy ipr adodcnetSaePeeecs mot nri.otn.hrdrfrne; ipr adodcnetSaePeeecsEio; mot nri.otn.hrdrfrne.dtr ipr adodo.ude mot nri.sBnl; ipr adodo.ade; mot nri.sHnlr ipr adodo.esg; mot nri.sMsae ipr adodui.o; mot nri.tlLg ipr adodve.iw mot nri.iwVe; ipr adodve.iwOCikitnr mot nri.iwVe.nlcLsee; ipr adodwde.utn mot nri.igtBto; ipr adodwde.ieraot mot nri.igtLnaLyu; ipr adodwde.etiw mot nri.igtTxVe; ipr adodwde.os; mot nri.igtTat ipr cmdobxcin2DobxP; mot o.rpo.let.rpoAI ipr cmdobxcin2adodAdoduheso; mot o.rpo.let.nri.nriAtSsin ipr cmdobxcin2ssinAcsTknar mot o.rpo.let.eso.cesoePi; ipr cmdobxcin2ssinApePi; mot o.rpo.let.eso.pKyar ipr cmdobxcin2ssinSsinAcsTp; mot o.rpo.let.eso.eso.cesye ipr cmdobxcin2ssinTknar mot o.rpo.let.eso.oePi; pbi casDobxciiyetnsAtvt ipeet OCikitnr{ ulc ls rpoAtvt xed ciiy mlmns nlcLsee
  4. 4. 2 5 2 6 2 7 2 8 2 9 3 0 3 1 3 2 3 3 3 4 3 5 3 6 3 7 3 8 3 9 4 0 4 1 4 2 4 3 4 4 4 5 4 6 4 7 4 8 4 9 5 0 5 1 5 2 5 3 5 4 5 5 5 6 5 7 5 8 5 9 6 0 6 1 6 2 6 3 6 4 6 5 6 6 6 7 6 8 6 9 7 0 7 1 7 2 7 3 7 4 7 5 7 6 7 7 7 8 7 9 8 0 piaeDobxP<nriAtSsin dobx rvt rpoAIAdoduheso> rpo; piaefnlsai Srn FL_I ="Dobxape" rvt ia ttc tig IEDR /rpoSml/; piaefnlsai Srn DOBXNM ="rpo_rf" rvt ia ttc tig RPO_AE dobxpes; piaefnlsai Srn ACS_E ="aqqblht" rvt ia ttc tig CESKY ytpy9s0u; piaefnlsai Srn ACS_ERT="sqko43l" rvt ia ttc tig CESSCE 9ido4yjr; piaeboeniLgeI; rvt ola sogdn piaeBto lgn rvt utn oI; piaeBto ulaFl; rvt utn podie piaeBto lsFls rvt utn itie; piaeLnaLyu cnanr rvt ieraot otie; @vrie Oerd pbi vi oCet(udesvdntnett){ ulc od nraeBnl aeIsacSae sproCet(aeIsacSae; ue.nraesvdntnett) stotnVe(.aotatvt_rpo) eCnetiwRlyu.ciiydobx; lgn=(utn fnVeBI(.ddobxlgn; oI Bto) idiwydRi.rpo_oi) lgnstnlcLsee(hs; oI.eOCikitnrti) ulaFl =(utn fnVeBI(.dula_ie; podie Bto) idiwydRi.podfl) ulaFl.eOCikitnrti) podiestnlcLsee(hs; lsFls=(utn fnVeBI(.dls_ie) itie Bto) idiwydRi.itfls; lsFlsstnlcLsee(hs; itie.eOCikitnrti) cnanr=(ieraot fnVeBI(.dcnanrfls; otie LnaLyu) idiwydRi.otie_ie) lgeI(as) ogdnfle; Adoduheso ssin nriAtSsin eso; ApePi pi =nwApePi(CESKY ACS_ERT; pKyar ar e pKyarACS_E, CESSCE) SaePeeecspes=gthrdrfrne(RPO_AE hrdrfrne rf eSaePeeecsDOBXNM, Srn ky=pesgttigACS_E,nl) tig e rf.eSrn(CESKY ul; Srn sce =pesgttigACS_ERT nl) tig ert rf.eSrn(CESSCE, ul; i (e ! nl & sce ! nl){ f ky = ul & ert = ul AcsTknartkn=nwAcsTknarky sce) cesoePi oe e cesoePi(e, ert; ssin=nwAdoduheso(ar AcsTp.P_ODR eso e nriAtSsinpi, cesyeAPFLE, }es { le ssin=nwAdoduheso(ar AcsTp.P_ODR; eso e nriAtSsinpi, cesyeAPFLE) } } dobx=nwDobxP<nriAtSsin(eso) rpo e rpoAIAdoduheso>ssin; @vrie Oerd poetdvi oRsm( { rtce od neue) sproRsm(; ue.neue) Adoduheso ssin=dobxgteso(; nriAtSsin eso rpo.eSsin) i (eso.uhniainucsfl) { f ssinatetctoScesu() ty{ r ssinfnsAtetcto(; eso.iihuhniain) Tknartkn =ssingtcesoePi(; oePi oes eso.eAcsTknar) SaePeeecspes=gthrdrfrne(RPO_A hrdrfrne rf eSaePeeecsDOBXNM
  5. 5. 8 1 8 2 8 3 8 4 8 5 8 6 8 7 8 8 8 9 9 0 9 1 9 2 9 3 9 4 9 5 9 6 9 7 9 8 9 9 10 0 11 0 12 0 13 0 14 0 15 0 16 0 17 0 18 0 19 0 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 10 3 11 3 12 3 13 3 14 3 15 3 16 3 Eio eio =pesei(; dtr dtr rf.dt) eio.uSrn(CESKY tkn.e) dtrpttigACS_E, oesky; eio.uSrn(CESSCE,tkn.ert; dtrpttigACS_ERT oessce) eio.omt) dtrcmi(; } } lgeI(re; ogdntu) }cth(leaSaexeto e { ac IlglttEcpin ) TatmkTx(hs "ro drn Dobxatetcto" os.aeetti, Err uig rpo uhniain TatLNT_HR)so(; os.EGHSOT.hw) } pbi vi lgeI(ola iLge){ ulc od ogdnboen sogd iLgeI =iLge; sogdn sogd ulaFl.eEaldiLge) podiestnbe(sogd; lsFlsstnbe(sogd; itie.eEaldiLge) lgnstetiLge ?"o ot :"o i"; oI.eTx(sogd Lg u" Lg n) } piaefnlHnlrhnlr=nwHnlr){ rvt ia ade ade e ade( pbi vi hnlMsaeMsaemg { ulc od adeesg(esg s) AryitSrn>rsl =mggtaa)gttigraLs( raLs<tig eut s.eDt(.eSrnAryit fr(tigflNm :rsl){ o Srn ieae eut Lgi"itie" flNm) o.(LsFls, ieae; TxVe t =nwTxVe(rpoAtvt.hs; etiw v e etiwDobxciiyti) t.eTx(ieae; vstetflNm) } ; } } cnanradiwt) otie.dVe(v; @vrie Oerd pbi vi oCikVe v { ulc od nlc(iw ) sic (.eI(){ wth vgtd) cs Ri.rpo_oi: ae .ddobxlgn i (sogdn { f iLgeI) dobxgteso(.nik) rpo.eSsin)uln(; lgeI(as) ogdnfle; }es { le dobxgteso(.trAtetcto(rpoAtvt. rpo.eSsin)satuhniainDobxciiy } bek ra; cs Ri.itfls ae .dls_ie: LsDobxie ls =nwLsDobxie(rpo,FL_I itrpoFls it e itrpoFlsdobx IEDR hnlr; ade) ls.xct(; iteeue) bek ra;
  6. 6. 17 3 18 3 19 3 10 4 11 4 12 4 13 4 14 4 15 4 16 4 17 4 cs Ri.podfl: ae .dula_ie UlaFlTDobxula =nwUlaFlTDobxti podieorpo pod e podieorpo(hs FL_I) IEDR; ula.xct(; podeeue) bek ra; } } dfut eal: bek ra; } Upload File to Dropbox using Android SDK 1 2 3 4 5 6 7 8 9 1 0 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 2 0 2 1 2 2 2 3 2 4 2 5 2 6 2 7 2 8 2 9 3 0 3 1 3 2 3 3 3 4 3 5 3 6 pcaecmjvtci.rposml; akg o.aaehgdobxape ? ipr jv.oFl; mot aai.ie ipr jv.oFlIpttem mot aai.ienuSra; ipr jv.oFlWie; mot aai.iertr ipr jv.oIEcpin mot aai.Oxeto; ipr adodcnetCnet mot nri.otn.otx; ipr adodo.snTs; mot nri.sAycak ipr adodwde.os; mot nri.igtTat ipr cmdobxcin2DobxP; mot o.rpo.let.rpoAI ipr cmdobxcin2ecpinDobxxeto; mot o.rpo.let.xeto.rpoEcpin pbi casUlaFlTDobxetnsAycakVi,Vi,Boen { ulc ls podieorpo xed snTs<od od ola> piaeDobxP<>dobx rvt rpoAI? rpo; piaeSrn pt; rvt tig ah piaeCnetcnet rvt otx otx; pbi UlaFlTDobxCnetcnet DobxP<>dobx ulc podieorpo(otx otx, rpoAI? rpo, Srn pt){ tig ah ti.otx =cnetgtplctoCnet) hscnet otx.eApiainotx(; ti.rpo =dobx hsdobx rpo; ti.ah=pt; hspt ah } @vrie Oerd poetdBoendIBcgon(od. prm){ rtce ola onakrudVi.. aas fnlFl tmDr=cnetgtahDr) ia ie epi otx.eCcei(; Fl tmFl; ie epie FlWie f; iertr r ty{ r tmFl =Fl.raeepie"ie,"tt,tmDr; epie iecetTmFl(fl" .x" epi) f =nwFlWie(epie; r e iertrtmFl) f.rt(Sml tx fl cetdfrdm proe Yumyu rwie"ape et ie rae o eo ups. o a s f.ls(; rcoe)
  7. 7. 3 7 3 8 3 9 4 0 4 1 4 2 4 3 4 4 4 5 4 6 4 7 4 8 4 9 5 0 5 1 5 2 5 3 5 4 5 5 5 6 5 7 5 8 5 9 6 0 6 1 6 2 FlIpttemflIpttem=nwFlIpttemtmFl) ienuSra ienuSra e ienuSra(epie dobxptiept +"etiett,flIpttem rpo.uFl(ah txfl.x" ienuSra, tmFl.egh) nl,nl) epielnt(, ul ul; tmFl.eee) epiedlt(; rtr tu; eun re }cth(Oxeto e { ac IEcpin ) epittcTae) .rnSakrc(; }cth(rpoEcpine { ac Dobxxeto ) epittcTae) .rnSakrc(; } } } rtr fle eun as; @vrie Oerd poetdvi oPsEeueBoenrsl){ rtce od notxct(ola eut i (eut { f rsl) TatmkTx(otx,"ieUlae Scsul!, os.aeetcnet Fl podd uefly" TatLNT_OG.hw) os.EGHLN)so(; }es { le TatmkTx(otx,"aldt ula fl" TatLNT_ os.aeetcnet Fie o pod ie, os.EGHL .hw) so(; } } List Dropbox Files using Android SDK 1 2 3 4 5 6 7 8 9 1 0 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 2 0 2 1 pcaecmjvtci.rposml; akg o.aaehgdobxape ? ipr jv.tlAryit mot aaui.raLs; ipr adodo.snTs; mot nri.sAycak ipr adodo.ude mot nri.sBnl; ipr adodo.ade; mot nri.sHnlr ipr adodo.esg; mot nri.sMsae ipr cmdobxcin2DobxP; mot o.rpo.let.rpoAI ipr cmdobxcin2DobxP.nr; mot o.rpo.let.rpoAIEty ipr cmdobxcin2ecpinDobxxeto; mot o.rpo.let.xeto.rpoEcpin pbi casLsDobxie etnsAycakVi,Vi,AryitSrn ulc ls itrpoFls xed snTs<od od raLs<ti piaeDobxP<>dobx rvt rpoAI? rpo; piaeSrn pt; rvt tig ah piaeHnlrhnlr rvt ade ade; pbi LsDobxie(rpoAI? dobx Srn pt,Hnlrhn ulc itrpoFlsDobxP<> rpo, tig ah ade a ti.rpo =dobx hsdobx rpo; ti.ah=pt; hspt ah ti.ade =hnlr hshnlr ade;
  8. 8. 2 2 2 3 2 4 2 5 2 6 2 7 2 8 2 9 3 0 3 1 3 2 3 3 3 4 3 5 3 6 3 7 3 8 3 9 4 0 4 1 4 2 4 3 4 4 4 5 4 6 4 7 4 8 } @vrie Oerd poetdAryitSrn>dIBcgon(od. prm){ rtce raLs<tig onakrudVi.. aas AryitSrn>fls=nwAryitSrn>) raLs<tig ie e raLs<tig(; ty{ r Etydrcoy=dobxmtdt(ah 10,nl,tu, nr ietr rpo.eaaapt, 00 ul re fr(nr ety:drcoycnet){ o Ety nr ietr.otns flsadetyflNm() ie.d(nr.ieae); } }cth(rpoEcpine { ac Dobxxeto ) epittcTae) .rnSakrc(; } } rtr fls eun ie; @vrie Oerd poetdvi oPsEeueAryitSrn>rsl){ rtce od notxct(raLs<tig eut Msaemgb =hnlrotiMsae) esg sOj ade.banesg(; Bnl b=nwBnl(; ude e ude) bpttigraLs(dt" rsl) .uSrnAryit"aa, eut; mgb.eDt() sOjstaab; hnlrsnMsaemgb) ade.edesg(sOj; } } Output

×