Android Intent Example - Javatpoint

文章推薦指數: 80 %
投票人數:10人

Android Intent is the message that is passed between components such as activities, content providers, broadcast receivers, services etc. It is generally used ... ⇧SCROLLTOTOP Home Android Java Servlet JSP Struts2 MailAPI Hibernate Spring DesignPattern Quiz Projects InterviewQ Comment AndroidTraining AndroidTutorial AndroidIntroduction WhatisAndroid HistoryandVersion AndroidArchitecture CoreBuildingBlocks AndroidEmulator InstallAndroid SetupEclipse HelloAndroidexample InternalDetails DalvikVM AndroidManifest.xml R.java HideTitleBar ScreenOrientation AndroidWidgets UIWidgets WorkingwithButton Toast CustomToast ToggleButton CheckBox CustomCheckBox RadioButton DynamicRadioButton CustomRadioButton AlertDialog Spinner AutoCompleteTextView ListView CustomListView RatingBar WebView SeekBar DatePicker TimePicker AnalogandDigital ProgressBar VerticalScrollView HorizontalScrollView ImageSwitcher ImageSlider ViewStub TabLayout TabLayoutwithFrameLayout SearchView SearchViewonToolbar EditTextwithTextWatcher ActivityandIntents ActivityLifeCycle ImplicitIntent ExplicitIntent StartActivityForResult ShareAppData AndroidFragments AndroidFragments AndroidMenu OptionMenu ContextMenu PopupMenu AndroidService AndroidService AndroidAlarmManager AndroidAlarmManager AndroidStorage AndroidPreferences InternalStorage ExternalStorage AndroidSQLite SQLiteTutorial SQLiteSpinner XMLandJSON XMLParsingSAX XMLParsingDOM XMLPullParser JSONParsing AndroidMultimedia MediaPlayer:Audio VideoView:Video RecordingMedia AndroidSpeech TextToSpeech1 TextToSpeech2 AndroidTelephony TelephonyManager GetCallState GetCallState2 SimpleCallerTalker PhoneCall SendSMS SendEmail AndroidDevice BluetoothTutorial ListPairedDevices WIFI CameraTutorial CameraTutorial SensorTutorial SensorTutorial AndroidGraphics AndroidGraphics AndroidAnimation AndroidAnimation AndroidWebService AndroidWebService GoogleMap AndroidGoogleMap CurrentLocation SearchLocation AddingAds AndroidGoogleAdmob 1)BannerAds 2)InterstitialAds AndroidExamples QR/BarCodeScanner RSSFeedReader VolleyFetchJSON AndroidLinkify IntroSlider RecyclerViewList SwipeDelRecyclerView SwipeRefreshActivity VolleyLibraryRegistrationLog-inLog-out NetworkConnectivityServices FirebaseAuthentication-GoogleLogin AndroidNotification UsingGooglereCAPTCHA AndroidSocial IntegratingGoogleSign-In IntegratingLinkedIn IntegratingTwitter AndroidVersions AndroidVersions AndroidKitKat AndroidLollipop AndroidMarshmallow AndroidNougat AndroidOreo AndroidPie Android10 AndroidMisc AndroidDeviceManager AndroidStudio AndroidAuto AndroidFileTransfer AndroidMessages AndroidTV AndroidScreenshot AndroidPay AndroidWatch AndroidPhones AndroidTablets AndroidFindMyPhone AndroidOne AndroidWearOS AndroidDataRecovery AndroidAntivirus Androidx86 AndroidvsiPhone EmulatorforPC AndroidFileManager Androidadblocker AndroidPodcastApp FortniteEpicGame FaceTimeforAndroid ShowBoxforAndroid AndroidAppStore VirusRemovalforAndroid ClearcacheAndroid RootAndroidDevice AndroidScreenRecorder BlockNumberonAndroid CanonprinterappforAndroid WirelessHPprinterappforAndroid HowtoUpdateAndroid iMessageforAndroid iCloudforAndroid CallRecorderforAndroid VideoderAndroidApk YouTubeVideoDownloaderforAndroid AirdropforAndroid RoboKillerforAndroid CleanmyAndroidPhone Howtohideapps,files,andphotosonAndroid BestweatherappswithwidgetsforAndroid FileTransferforMac MobdroforAndroid AndroidScreenMirroring Stockmarketapps turnOnorOffsafemode BestbrowsersforAndroid BestclocksforAndroid BestemailappsforAndroid MusicplayerforAndroid Androidsmartwatchforwomen BestkeyboardforAndroid BestmessagingappforAndroid DevicecleanerandboosterforAndroid Wi-FicallingonAndroid GoogleAssistantappforAndroid HowtodeleteappsonAndroid NortonSecurityandAntivirusforAndroid RadioappsforAndroid StockAndroid SkypeforAndroid HowtotransfercontactsfromAndroidtoiPhone AlexaappforAndroid BestCasinoGamesforAndroid VolumeboosterforAndroid HowtoupdateappsonAndroid EpsonPrintEnablerforAndroid PrinterappsforAndroid AndroidBeam ParanoidAndroid DoNotDisturbinAndroid HowtogetAndroidMessagesonPC AndroidDarkMode QVCappforAndroid WeatherUndergroundapp WhatisNFConAndroid ScreentimeAndroid SearchbyImage:GoogleReverseImageSearch HowtorecordscreenonAndroid HowtosplitscreenonAndroid RedditappforAndroid TweakBoxforAndroid BestPS2EmulatorsforAndroid Pop-upBlockerinAndroid AndroidEasterEgg DrudgereportAndroidapps 3DSEmulatorAndroid TerrariumTVAppforAndroid BestAndroidCleanerApps SpectrumTVAppforAndroid Android11 RadarDetectorApps HotspotappsforAndroid HowtoTransferContactsfromiPhonetoAndroid AmazonappstoreforAndroid HangoutsAppforAndroid OmegleVideoChatonAndroid OutlookAppforAndroidMobile AnimojiforAndroid Whatiscontent://com.android.browser.home/ FirefoxforAndroid MovieAppsforAndroid POFFreeDatingAppforAndroid PS4RemotePlayforAndroid BestAndroidGames BestAndroidTVBoxes HowtoClearCookiesonAndroid HowtoResetAndroidPhone MalwarebytesforAndroid HowtoFindWi-FiPasswordonAndroid HowtoInstallAPKonAndroid HowtoUnlockAndroidPhone HowtoBlockTextMessagesonAndroid HowtoRecoverDeletedTextMessagesandPhotosonAndroid HowtoRemovePreviouslySyncedGoogleAccountfromAndroid HowtoTransferContactsfromAndroidtoAndroid HowtoSetupVoicemailonAndroid HowtoShareWi-FiPasswordfromiPhonetoAndroid HowtoBackupAndroidPhone WhatVersionofAndroidDoIHave HowtoBlockWebsiteonAndroidPhoneandComputer TurnonFlashinChrome FreeMusicDownloadermp3forAndroid WhoOwnsAndroid BestNotesAppforAndroid BarcodescannerappsforAndroid HowtoConnectAndroidPhonetoTV BestfreeVPNforAndroid DownloadGooglePlayStoreAppforAndroid DoAirPodsworkwithAndroid HowtoDownloadMusicfromYoutubeonAndroid HowtoEmptyTrashonAndroid HowtoPrintTextMessagesfromAndroid HowtoShareLocationonAndroid HowtochangekeyboardonAndroidphone HowtoHackWi-FipasswordinAndroid Howtoalloworblockpop-upsinChromebrowser HowtoEnableCookiesonAndroid HowtoseeablockednumberandunblockthemonAndroid HowtoTrackiPhonefromanAndroidPhone WhatismyPhoneNumberonAndroid BestPoliceRadarDetector HowtoopenTIForTIFFfilesonAndroid AndroidFinalYearProjectIdeasforComputerScience AndroidMessagesforweb HowtoChangeFontStyleinAndroidPhone IPAddressFormatandTable BestOfflineAndroidGames BestCameraApps DoesAppleWatchWorkwithAndroid FastestAndroidEmulators HowtoTakeascreenshotinAndroidphone BestWirelessEarbudsforAndroid HowtoLockAppsonAndroid HowtoturnoffGoogleAssistantonAndroid ParentalcontrolAndroidapps VideoplayerforAndroid HowtoScreenMirrororCastAndroidphoneontheTV BestLearningAppsforKids HowtoScanQRCodeonanAndroid HowtoFindHiddenAppsonAndroid HowtoDeleteDownloadsonAndroid HowtoRecoverDeletedVideosfromAndroid BestGuitarLearningApps ExtramarksLearningApp VedantuLearningApp HowtoCopyandPasteonyourAndroid HowtoLeaveaGroupTextonAndroidandiPhone HowtoturnoffAMBERAlertsonyourAndroiddevice HowtoMoveAppstoSDCardonAndroid HowtodeletePreinstalledAppsonAndroid HowdoIDeleteGoogleHistoryonmyAndroidPhone HowtocloseappsonAndroid HowtoForwardCallsonAndroid HowtoVideoCallonAndroid HowtoDeleteGmailAccountonAndroidPhone HowtoGetiPhoneEmojisonAndroid HowtoCheckAirpodBatteryonAndroid HowtodownloadappsonAndroid HowdoIDisableScreenLockonAndroid HowtotransfermessagesfromAndroidtoiPhone HowtoUnziporExtractFilesonAndroidDevice HowtoBlockUnknownNumbersonAndroid HowtoConnectXboxOneControllertoAndroid HowtoMakeaConferenceCallonAndroid HowtoDeleteallEmailsatonceonAndroid HowtoMakeYourNumberPrivateonAndroid HowtomakeasongasaringtoneonAndroid HowtoCancelAppSubscriptiononAndroid HowDoYouKnowIfSomeoneBlockedYourNumberonAndroid HowtoPlayAndroidGamesonPC HowtoSaveTextMessagesonAndroid WhereisClipboardonAndroidPhone HowCanYouGetAppleMusiconAndroid HowtoAutomaticallyRecordPhoneCallsonAndroid HowtoFindDownloadsonAndroid HowtoSignOutofGoogleonAndroid WhyWon'tMyTextMessagesSendOnMyAndroid HowdoIActivateVoicetoTextonAndroid HowtoConnectBeatsWirelesstoAndroid,iPhone,Windows,Mac HowtoAccessiCloudPhotosonAndroid HowtoDownloadFacebookVideosonAndroid HowtoAccessiCloudPhotosonAndroid HowtoDownloadFacebookVideosonAndroid HowtoDeleteInstagramAccountonAndroid HowtoSetAlarmonAndroid HowtofreeupspaceonanAndroidphone WhyDoesMyAndroidPhoneSayNoService HowtolistentoPodcastsonAndroid HowtoSetupaVPNonAndroidandiPhone HowtoTransferappsfromAndroidtoAndroid HowtoUseFaceTimeonAndroidorWindows HowtoGetDarkModeonInstagramonAndroidandiPhone HowtoActivateDoNotDisturbWhileDrivingonAndroid HowtotransferappsfromAndroidtoiPhone HowtotransferfilesfromAndroidtoPC HowtoChangeLanguageonAndroid HowtoChangeIPAddressonAndroid HowtoPlayiMessageGamesonanAndroidphone HowtoRotateVideosonAndroid HowtofindtheIMEInumberonAndroid HowtotransferphotosfromAndroidtoMac HowtoCropaVideoonAndroid HowtoUpdateAndroidTablet HowtoCancelSpotifyPremiumonAndroid HowtoCancelTinderGoldonAndroid BestCompassAppforAndroid HowtoRestoreAndroidPhonefromGoogleBackup HowtotransferWhatsAppfromAndroidtoiPhone HowtoSetaReminderonAndroid HowtoTransferPhotosfromAndroidtoAndroid IsSamsunganAndroid HowtoEnableorDisableDeveloperOptionsonAndroid ProxyBrowserAppsforAndroid ChromeDarkModeonAndroid Howtofix"androidprocessacore"hasstoppederrorsonAndroid CanwerunSiriforAndroid FreePDFEditorappsforAndroid HowtoConnectAndroidAutoandAppleCarPlayinToyota HowtoviewsavedpasswordsinChromeonAndroid HowtoDownloadYouTubevideosonAndroid HowtoSetupAndroidAuto HowtotextfromComputertoAndroidMessages ChromecastappsforAndroid HowtobackupContactsonAndroid BestDSEmulatorforAndroid FitbitappforAndroid WhatisAndroidAccessibilitySuite HowtoTetherAndroidPhone HowtocloseappsonAndroid AndroidAPILevels HowtoenableFacebookDarkModeonAndroid BestScreenSharingAppsforAndroidandiPhone GoogleWeatherAppforAndroid EndoscopeAppforAndroid AudibleappforAndroid AndroidMCQ AndroidMCQ AndroidInterview InterviewQuestions AndroidQuiz AndroidQuiz next→ ←prev AndroidIntentTutorial AndroidIntentisthemessagethatispassedbetweencomponentssuchasactivities,contentproviders,broadcastreceivers,servicesetc. ItisgenerallyusedwithstartActivity()methodtoinvokeactivity,broadcastreceiversetc. Thedictionarymeaningofintentisintentionorpurpose.So,itcanbedescribedastheintentiontodoaction. TheLabeledIntentisthesubclassofandroid.content.Intentclass. Androidintentsaremainlyusedto: Starttheservice Launchanactivity Displayawebpage Displayalistofcontacts Broadcastamessage Dialaphonecalletc. TypesofAndroidIntents Therearetwotypesofintentsinandroid:implicitandexplicit. 1)ImplicitIntent ImplicitIntentdoesn'tspecifiythecomponent.Insuchcase,intentprovidesinformationofavailablecomponentsprovidedbythesystemthatistobeinvoked. Forexample,youmaywritethefollowingcodetoviewthewebpage. Intentintent=newIntent(Intent.ACTION_VIEW); intent.setData(Uri.parse("http://www.javatpoint.com")); startActivity(intent); 2)ExplicitIntent ExplicitIntentspecifiesthecomponent.Insuchcase,intentprovidestheexternalclasstobeinvoked. Intenti=newIntent(getApplicationContext(),ActivityTwo.class); startActivity(i); Togetthefullcodeofexplicitintent,visitthenextpage. AndroidImplicitIntentExample Let'sseethesimpleexampleofimplicitintentthatdisplaysawebpage. activity_main.xml File:activity_main.xml Activityclass File:MainActivity.java packageexample.javatpoint.com.implicitintent; importandroid.content.Intent; importandroid.net.Uri; importandroid.support.v7.app.AppCompatActivity; importandroid.os.Bundle; importandroid.view.View; importandroid.widget.Button; importandroid.widget.EditText; publicclassMainActivityextendsAppCompatActivity{ Buttonbutton; EditTexteditText; @Override protectedvoidonCreate(BundlesavedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); button=findViewById(R.id.button); editText=findViewById(R.id.editText); button.setOnClickListener(newView.OnClickListener(){ @Override publicvoidonClick(Viewview){ Stringurl=editText.getText().toString(); Intentintent=newIntent(Intent.ACTION_VIEW,Uri.parse(url)); startActivity(intent); } }); } } Output: NextTopicAndroidExplicitIntentExample ←prev next→ ForVideosJoinOurYoutubeChannel:JoinNow Feedback SendyourFeedbackto[email protected] HelpOthers,PleaseShare LearnLatestTutorials Splunk SPSS Swagger Transact-SQL Tumblr ReactJS Regex ReinforcementLearning RProgramming RxJS ReactNative PythonDesignPatterns PythonPillow PythonTurtle Keras Preparation Aptitude Reasoning VerbalAbility InterviewQuestions CompanyQuestions TrendingTechnologies ArtificialIntelligence AWS Selenium CloudComputing Hadoop ReactJS DataScience Angular7 Blockchain Git MachineLearning DevOps B.Tech/MCA DBMS DataStructures DAA OperatingSystem ComputerNetwork CompilerDesign ComputerOrganization DiscreteMathematics EthicalHacking ComputerGraphics SoftwareEngineering WebTechnology CyberSecurity Automata CProgramming C++ Java .Net Python Programs ControlSystem DataMining DataWarehouse JavatpointServicesJavaTpointofferstoomanyhighqualityservices.Mailuson[email protected],togetmoreinformationaboutgivenservices.WebsiteDesigningWebsiteDevelopmentJavaDevelopmentPHPDevelopmentWordPressGraphicDesigningLogoDigitalMarketingOnPageandOffPageSEOPPCContentDevelopmentCorporateTrainingClassroomandOnlineTrainingDataEntryTrainingForCollegeCampusJavaTpointofferscollegecampustrainingonCoreJava,AdvanceJava,.Net,Android,Hadoop,PHP,WebTechnologyandPython.Pleasemailyourrequirementat[email protected]Duration:1weekto2weekLike/Subscribeusforlatestupdatesornewsletter



請為這篇文章評分?