קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
מערכת Android מאפשרת לכם, כמפתחים, להשתמש ביכולות של האינטרנט באפליקציות שלכם, כך שתוכלו ליהנות מהגמישות והיעילות של הצגת סוגים מסוימים של תוכן.
כך אפשר לשלב בצורה חלקה תוכן אינטרנט קיים באפליקציית Android מקורית, למשל כדי להציג פיד חדשות, להציג הדרכות אינטראקטיביות, להציג מודעות או אפילו לארח משחק מיני בלי לבנות הכול מאפס.
אפשר לחשוב על זה כחלון לאינטרנט מתוך האפליקציה. יש שתי דרכים להטמעת תוכן אינטרנט באפליקציה:
WebView: הוא מציג תוכן אינטרנט שאתם שולטים בו בתוך השורה, במקום שבו אתם רוצים גמישות גבוהה בהתאמה אישית או בעדכון של ממשק המשתמש.
כרטיסיות בהתאמה אישית:
חוויית גלישה מלאה בתוך האפליקציה, שמופעלת על ידי דפדפן ברירת המחדל של המשתמש
(ראו תמיכה בדפדפנים). הכרטיסיות האלה מיועדות למקרים שבהם משתמשים לוחצים על קישור ואתם רוצים שהם יישארו באפליקציה, במקום לעבור לדפדפן חיצוני. רוב חוויית הגלישה זמינה מחוץ לקופסה.
איור 1. WebView (משמאל) וכרטיסייה בהתאמה אישית (מימין) מודגשים.
למה כדאי להטמיע תוכן אינטרנטי?
יעילות: שימוש חוזר בקוד קיים מהאתר. להתבסס על טכנולוגיות ותוכן קיימים באינטרנט.
שילוב: שימוש בתוכן חיצוני מספקי צד שלישי, כמו מדיה ומודעות, באפליקציה.
גמישות: אפשר לעדכן את התוכן באופן דינמי בלי להיות מוגבלים לממשקי משתמש מוגדרים מראש, או בלי לפרסם עדכונים לאפליקציה.
מתי כדאי להשתמש בתוכן אינטרנט?
יש שלושה תרחישי שימוש עיקריים לשימוש באינטרנט באפליקציה ל-Android:
הצגת תוכן אינטרנט משלכם בתוך השורה כחוויה ראשית, במקומות שבהם אתם רוצים מידה גבוהה של גמישות בהתאמה אישית או בעדכון של ממשק המשתמש.
הצגת תוכן אחר כמו מודעות, תנאים והגבלות משפטיים, תקנות או תוכן אחר של צד שלישי בתוך חוויית השימוש באפליקציה או כחלון בתוכה.
איור 2. תוכן מהאינטרנט שמוטמע באפליקציה באמצעות רכיבי WebView כתוכן ראשי (מימין) ותוכן תומך (משמאל).
2. גלישה בתוך האפליקציה באמצעות כרטיסיות מותאמות אישית או WebView לתרחישי שימוש מתקדמים יותר
ליהנות מחוויית גלישה מלאה בתוך האפליקציה כשמשתמשים לוחצים על קישור ואתם רוצים שהם יישארו באפליקציה ולא יעברו לדפדפן חיצוני.
הערה: במכשירים עם מסך גדול, כמו טאבלטים ומכשירים מתקפלים, יש אפשרויות נוספות שיעזרו לאפליקציות לנצל את השטח הנוסף:
אפליקציות יכולות לפתוח קישורי אינטרנט במסך מפוצל באמצעות הפעלת חוויית ריבוי חלונות סמוכה. כך המשתמשים יכולים לבצע כמה משימות בו-זמנית באפליקציה ובדפדפן. או
לכרטיסיות בהתאמה אישית יש אפשרות של חלונית צדדית שאפשר לפתוח באותה משימה, אבל לצד התוכן הקיים באפליקציה.
הכרטיסייה המותאמת אישית מופעלת על ידי דפדפן ברירת המחדל של המשתמש, בדפדפנים שתומכים בכרטיסיות מותאמות אישית.
אפשר להשתמש ב-WebView כדי לספק חוויית גלישה באפליקציה שניתנת להתאמה אישית, אבל אנחנו ממליצים להשתמש בכרטיסיות מותאמות אישית כדי לספק חוויית גלישה מוכנה לשימוש ומעבר חלק כשמשתמש רוצה לפתוח קישור לאתר בדפדפן.
איור 3. לחיצה על קישור בתוך האפליקציה (מימין) ופתיחת דפדפן בתוך האפליקציה (משמאל).
3. תהליכי כניסה או אימות באפליקציה
הגישה המומלצת ב-Android היא ליצור את תהליכי הכניסה או האימות באמצעות המרכז לניהול פרטי כניסה. אם אתם עדיין צריכים להשתמש ב-Embedded Web כדי ליהנות מהחוויה הזו, תוכלו להיעזר בהנחיות הבאות:
חלק מהאפליקציות משתמשות ב-WebViews כדי לספק למשתמשים תהליכי כניסה, כולל שימוש בשם משתמש ובמפתח גישה (או בסיסמה) שספציפיים לאפליקציה. כך המפתחים יכולים לאחד את תהליכי האימות בפלטפורמות שונות.
כשמקשרים לספק זהויות או לחוויית כניסה של צד שלישי, כמו 'כניסה באמצעות…', כדאי להשתמש בכרטיסיות בהתאמה אישית. הפעלת כרטיסיות בהתאמה אישית מבטיחה שפרטי הכניסה של המשתמש יישארו מוגנים ומבודדים באתר של הצד השלישי.
איור 4. שדה כניסה באפליקציה (מימין) וכניסה דרך צד שלישי שנפתחה בכרטיסייה בהתאמה אישית (משמאל).
דוגמאות התוכן והקוד שבדף הזה כפופות לרישיונות המפורטים בקטע רישיון לתוכן. Java ו-OpenJDK הם סימנים מסחריים או סימנים מסחריים רשומים של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-08-21 (שעון UTC).
[null,null,["עדכון אחרון: 2025-08-21 (שעון UTC)."],[],[],null,["# Use web content within your Android app\n\nAndroid allows you as a developer to build on the power of the web within your\napps, so you can benefit from the flexibility and efficiency of being able to\ndisplay certain types of content.\n\nThis lets you seamlessly integrate existing web content into your native\nAndroid application, such as to display a news feed, show interactive tutorials,\ndisplay ads, or even host a mini-game without building everything from scratch.\nThink of it as a window to the internet, from within your app. There are two\nways to embed web content into your app:\n\n- [WebView](/reference/android/webkit/WebView): It displays web content you control inline where you want a high degree of flexibility in customizing or updating the UI.\n- [Custom Tabs](/develop/ui/views/layout/webapps/overview-of-android-custom-tabs): A full in-app browsing experience powered by the user's default browser ([see browser support](https://developer.chrome.com/docs/android/custom-tabs/browser-support)) for when users click a link and you want to keep them in the app, instead of leaving to an external browser, with much of the browsing experience out-of-the-box.\n\n**Figure 1.** WebView (left) and Custom Tab (right) outlined.\n\nWhy embed web content?\n----------------------\n\n- Efficiency: Reuse existing code from your website. Build on existing web technologies and content.\n- Integration: Leverage external content from 3P providers, such as Media, Ads, within your app.\n- Flexibility: Update content dynamically without being constrained to predefined UIs, or without releasing app updates.\n\nWhen to use web content?\n------------------------\n\nThere are three primary uses cases for using the Web in your Android app:\n\n**1. [Embedding web content into your app as primary or supporting content](/develop/ui/views/layout/webapps/embed-web-content-in-app): Use WebView**\n\n- Display your own web content inline as a primary experience where you want a high degree of flexibility in customizing or updating the UI.\n- Display other content such as ads, legal terms and regulations, or other third-party content inline, or as a window within your app experience.\n\n**Figure 2.** Web content embedded within the app with WebViews as primary (left) and supporting content (right).\n\n**2. [In-app browsing](/develop/ui/views/layout/webapps/in-app-browsing-embedded-web?) using Custom Tabs, or WebView for more advanced use cases**\n\n- Have a full in-app browsing experience for when users click a link and you want to keep them in the app, instead of leaving to an external browser.\n - Note: For large screen devices such as tablets and foldables, there are additional options to help apps take advantage of additional space:\n - Apps can open weblinks in split screen using [launch an adjacent multi-window experience](/develop/ui/compose/layouts/adaptive/support-multi-window-mode#launch_adjacent). This enables users to multitask between your app and a browser at the same time. OR\n - Custom Tabs have a side panel option that can open in the same task, but next to your existing app content.\n- The Custom Tab is powered by the user's default browser, for browsers which support Custom Tabs.\n - While it's possible to use a WebView and provide a highly customizable in-app browsing experience, we recommend Custom tabs for an out-of-the-box browser experience and seamless transition for when a user wants to open a web link in the browser.\n\n**Figure 3.** Clicking on an in-app link (left) and opening an in-app browser (right).\n\n**3. Login or Authentication flows within your app**\n\nAndroid's suggested approach is to build your login or authentication flows\nusing [Credential Manager](/identity/sign-in/credential-manager). If you find\nyou still need to use Embedded Web for these experiences, use the following\nguidance:\n\n- Some apps use WebViews to provide sign-in flows for their users, including using a username and passkey (or password) specific to your app. This enables developers to unify the authentication flows across platforms.\n- When linking out to a third-party identity provider or login experience, such as \"Sign in with...\", Custom Tabs are the way to go. Launching Custom Tabs ensures the user's credential remains protected and isolated to the 3rd party site.\n\nFor more information about leveraging WebViews for authentication,\nsee [Authenticate users with WebView](/identity/sign-in/credential-manager-webview).\nFor launching a Custom Tab, see [Overview of Android Custom Tabs](/develop/ui/views/layout/webapps/overview-of-android-custom-tabs).\n**Figure 4.** An in-app login field (left) and a third-party login opened in a Custom Tab (right)."]]