Intents introduction and importance, types of intents in Hindi
Introduction to Intents:
- Intent Android में एक Messaging Object है, जो Components (Activities, Services, Broadcast Receivers) के बीच Communication के लिए Use होता है।
- Intent का उपयोग एक Activity से दूसरी Activity को Start करने, Data Pass करने, और Background Services चलाने के लिए किया जाता है।
- यह दो प्रकार के होते हैं: Explicit Intent (जहाँ Target Component Specify किया जाता है) और Implicit Intent (जहाँ System Decide करता है कि कौन-सा Component Handle करेगा)।
- Intent के माध्यम से हम Data Transfer कर सकते हैं, जैसे कि String, Integer, Boolean, ArrayList, और Parcelable Objects।
- Intent में Extras का उपयोग किया जाता है, जिससे हम Key-Value Pair के रूप में Additional Information भेज सकते हैं।
- Intent का उपयोग System Features को Access करने के लिए भी किया जाता है, जैसे कि Camera Open करना, Web Page Load करना, या Call करना।
- startActivity() Method का उपयोग Intent से नई Activity Launch करने के लिए किया जाता है।
- startActivityForResult() Method से हम किसी Activity से Result वापस प्राप्त कर सकते हैं, जैसे कि Image Picker से चुनी गई Image।
- Broadcast Messages भेजने और Receive करने के लिए भी Intent का उपयोग किया जाता है, जैसे कि Battery Low या Airplane Mode Change का Notification।
- Intent Filter के माध्यम से App यह Decide कर सकता है कि कौन-सा Intent Handle करना है, जिससे Apps के बीच Interaction आसान हो जाता है।
Importance of Intents:
- Intent Android में Component Communication का मुख्य जरिया है, जिससे Activities, Services, और Broadcast Receivers आपस में बातचीत कर सकते हैं।
- यह एक Activity से दूसरी Activity पर जाने और Navigation को आसान बनाता है।
- Intent का उपयोग Data Transfer के लिए किया जाता है, जिससे Apps के अंदर या दूसरी Apps के साथ Information Share की जा सकती है।
- यह System Features को Access करने में मदद करता है, जैसे कि Camera Open करना, Web Browser Launch करना, और Call करना।
- Implicit Intents की मदद से Apps आपस में Interact कर सकते हैं, जैसे कि किसी App से Image Select कर दूसरी App में Send करना।
- Intent Multitasking को Support करता है, जिससे Background में Services को Start और Stop किया जा सकता है।
- Broadcast Messages भेजने और Receive करने में मदद करता है, जिससे System Events (जैसे Battery Low, Network Change) को Handle किया जा सकता है।
- startActivityForResult() से किसी दूसरी Activity से Data (जैसे User Input, Image) वापस प्राप्त किया जा सकता है।
- Intent Filter की मदद से किसी App का कोई Specific Action Handle किया जा सकता है, जिससे Apps के बीच Seamless Integration संभव होता है।
- Android के Security और Permissions Model में भी Intent का महत्वपूर्ण योगदान है, जिससे User Control और Privacy बनाए रखी जाती है।
Types of Intents:
1. Explicit Intent
- जब Intent में सटीक Component (Activity, Service) को Specify किया जाता है, तो उसे Explicit Intent कहते हैं।
- इसका उपयोग एक Activity से दूसरी Activity पर जाने या Background Service Start करने के लिए किया जाता है।
Example: (Java code)
Intent intent = new Intent(MainActivity.this, SecondActivity.class);
startActivity(intent);
2. Implicit Intent
- जब Intent में Target Component Define नहीं किया जाता, बल्कि Action (जैसे SEND, VIEW, DIAL) के आधार पर System Decide करता है कि कौन-सा Component इसे Handle करेगा, तो उसे Implicit Intent कहते हैं।
- इसका उपयोग System Features (जैसे Web Browser, Dialer, Camera) को Open करने या दूसरी Apps के साथ Interaction के लिए किया जाता है।
Example: (Java code)
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("https://www.google.com"));
startActivity(intent);
Page Views
0
Visit ID
Not tracked yet
Visit Time
-
Time on Page
0 seconds
Request
Leave a Comment
INITIALIZING...
INITIALIZING...
Quizzes in Hindi
GK Online Quiz in Hindi
10 pages
HTML Online Quiz in Hindi
10 pages
CSS Online Quiz in Hindi
10 pages
JavaScript Online Quiz in Hindi
10 pages
CCC Online Quiz in Hindi
10 pages
Comments Total: 0 comments