সেভ করা পৃষ্ঠা গুছিয়ে রাখতে 'সংগ্রহ' ব্যবহার করুন
আপনার পছন্দ অনুযায়ী কন্টেন্ট সেভ করুন ও সঠিক বিভাগে রাখুন।
যদি আপনার অ্যাপ ওয়েব কন্টেন্ট প্রদর্শনের জন্য WebView ব্যবহার করে, তাহলে এটি কনফিগার করার পরামর্শ দেওয়া হয় যাতে বিজ্ঞাপনের মাধ্যমে কন্টেন্টকে সর্বোত্তমভাবে নগদীকরণ করা যায়।
এই নির্দেশিকা আপনাকে দেখায় কিভাবে একটি WebView অবজেক্ট কনফিগার করতে হয় সে সম্পর্কে তথ্য প্রদান করতে হয়।
তৃতীয় পক্ষের কুকিজ সক্ষম করুন
আপনার ব্যবহারকারীর বিজ্ঞাপনের অভিজ্ঞতা উন্নত করতে এবং Chrome এর কুকি নীতির সাথে সামঞ্জস্যপূর্ণ হতে, আপনার WebView উদাহরণে তৃতীয় পক্ষের কুকি সক্ষম করুন৷
ডিফল্ট WebView সেটিংস বিজ্ঞাপনের জন্য অপ্টিমাইজ করা হয় না। এর জন্য আপনার WebView কনফিগার করতে WebSettings API ব্যবহার করুন:
জাভাস্ক্রিপ্ট
স্থানীয় স্টোরেজ অ্যাক্সেস
স্বয়ংক্রিয় ভিডিও প্লে
জাভা
importandroid.webkit.CookieManager;importandroid.webkit.WebView;publicclassMainActivityextendsAppCompatActivity{privateWebViewwebView;@OverrideprotectedvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);webView=findViewById(R.id.webview);// Let the web view accept third-party cookies.CookieManager.getInstance().setAcceptThirdPartyCookies(webView,true);// Let the web view use JavaScript.webView.getSettings().setJavaScriptEnabled(true);// Let the web view access local storage.webView.getSettings().setDomStorageEnabled(true);// Let HTML videos play automatically.webView.getSettings().setMediaPlaybackRequiresUserGesture(false);}}
কোটলিন
importandroid.webkit.CookieManagerimportandroid.webkit.WebViewclassMainActivity:AppCompatActivity(){lateinitvarwebView:WebViewoverridefunonCreate(savedInstanceState:Bundle?){super.onCreate(savedInstanceState)setContentView(R.layout.activity_main)webView=findViewById(R.id.webview)// Let the web view accept third-party cookies.CookieManager.getInstance().setAcceptThirdPartyCookies(webView,true)// Let the web view use JavaScript.webView.settings.javaScriptEnabled=true// Let the web view access local storage.webView.settings.domStorageEnabled=true// Let HTML videos play automatically.webView.settings.mediaPlaybackRequiresUserGesture=false}}
ওয়েব ভিউ কন্টেন্ট লোড করুন
কুকি এবং পৃষ্ঠার URLগুলি ওয়েব ভিউ নগদীকরণের জন্য গুরুত্বপূর্ণ এবং শুধুমাত্র প্রত্যাশিতভাবে কাজ করে যখন loadUrl() একটি নেটওয়ার্ক-ভিত্তিক URL এর সাথে ব্যবহার করা হয়। অপ্টিমাইজ করা WebView পারফরম্যান্সের জন্য, নেটওয়ার্ক-ভিত্তিক URL থেকে সরাসরি ওয়েব সামগ্রী লোড করুন। WebViewAssetLoader ব্যবহার করা, ডিভাইস থেকে সম্পদ লোড করা, বা গতিশীলভাবে ওয়েব সামগ্রী তৈরি করা এড়িয়ে চলুন।
জাভা
importandroid.webkit.CookieManager;importandroid.webkit.WebView;publicclassMainActivityextendsAppCompatActivity{privateWebViewwebView;@OverrideprotectedvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);webView=findViewById(R.id.webview);// Let the web view accept third-party cookies.CookieManager.getInstance().setAcceptThirdPartyCookies(webView,true);// Let the web view use JavaScript.webView.getSettings().setJavaScriptEnabled(true);// Let the web view access local storage.webView.getSettings().setDomStorageEnabled(true);// Let HTML videos play automatically.webView.getSettings().setMediaPlaybackRequiresUserGesture(false);// Load the URL for optimized web view performance.webView.loadUrl("https://google.github.io/webview-ads/test/");}}
কোটলিন
importandroid.webkit.CookieManagerimportandroid.webkit.WebViewclassMainActivity:AppCompatActivity(){lateinitvarwebView:WebViewoverridefunonCreate(savedInstanceState:Bundle?){super.onCreate(savedInstanceState)setContentView(R.layout.activity_main)webView=findViewById(R.id.webview)// Let the web view accept third-party cookies.CookieManager.getInstance().setAcceptThirdPartyCookies(webView,true)// Let the web view use JavaScript.webView.settings.javaScriptEnabled=true// Let the web view access local storage.webView.settings.domStorageEnabled=true// Let HTML videos play automatically.webView.settings.mediaPlaybackRequiresUserGesture=false// Load the URL for optimized web view performance.webView.loadUrl("https://google.github.io/webview-ads/test/")}}
ওয়েব ভিউ পরীক্ষা করুন
অ্যাপ বিকাশের সময়, আমরা আপনাকে এই পরীক্ষার URL লোড করার পরামর্শ দিই:
এই সেটিংস বিজ্ঞাপনে অভিপ্রেত প্রভাব আছে যাচাই করতে. পরীক্ষার URL এর একটি সম্পূর্ণ একীকরণের জন্য সাফল্যের মানদণ্ড রয়েছে যদি নিম্নলিখিতগুলি পর্যবেক্ষণ করা হয়:
ওয়েব ভিউ সেটিংস
তৃতীয় পক্ষের কুকি কাজ করে
প্রথম পক্ষের কুকি কাজ করে
জাভাস্ক্রিপ্ট সক্রিয়
DOM সঞ্চয়স্থান সক্ষম
ভিডিও বিজ্ঞাপন
ভিডিও বিজ্ঞাপনটি ইনলাইনে চলে এবং সম্পূর্ণ স্ক্রীন বিল্ট-ইন প্লেয়ারে খোলে না
ভিডিও বিজ্ঞাপনটি প্লে বোতামে ক্লিক না করেই স্বয়ংক্রিয়ভাবে চলে
ভিডিও বিজ্ঞাপনটি রিপ্লেযোগ্য
পরীক্ষা সম্পূর্ণ হওয়ার পরে, ওয়েব ভিউ লোড করতে চায় এমন URL দিয়ে পরীক্ষার URL প্রতিস্থাপন করুন।
[[["সহজে বোঝা যায়","easyToUnderstand","thumb-up"],["আমার সমস্যার সমাধান হয়েছে","solvedMyProblem","thumb-up"],["অন্যান্য","otherUp","thumb-up"]],[["এতে আমার প্রয়োজনীয় তথ্য নেই","missingTheInformationINeed","thumb-down"],["খুব জটিল / অনেক ধাপ","tooComplicatedTooManySteps","thumb-down"],["পুরনো","outOfDate","thumb-down"],["অনুবাদ সংক্রান্ত সমস্যা","translationIssue","thumb-down"],["নমুনা / কোড সংক্রান্ত সমস্যা","samplesCodeIssue","thumb-down"],["অন্যান্য","otherDown","thumb-down"]],["2025-08-23 UTC-তে শেষবার আপডেট করা হয়েছে।"],[[["\u003cp\u003eThis guide explains how to configure Android \u003ccode\u003eWebView\u003c/code\u003e for optimal ad monetization by enabling features like third-party cookies, JavaScript, and local storage access.\u003c/p\u003e\n"],["\u003cp\u003eIt is crucial to apply all recommendations to every \u003ccode\u003eWebView\u003c/code\u003e instance in your app for consistent ad performance.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers should use \u003ccode\u003eloadUrl()\u003c/code\u003e with network-based URLs directly to ensure proper functionality of cookies and optimized web view performance.\u003c/p\u003e\n"],["\u003cp\u003eA provided test URL helps verify the effectiveness of your settings for ad integration during development.\u003c/p\u003e\n"],["\u003cp\u003eFor production, replace the test URL with the intended URL for your \u003ccode\u003eWebView\u003c/code\u003e to load.\u003c/p\u003e\n"]]],[],null,["If your app utilizes `\n`[`WebView`](//developer.android.com/reference/android/webkit/WebView) to display web content, it's\nrecommended to configure it so that content can be optimally monetized with ads.\n\nThis guide shows you how to provide information about how to configure a\n`WebView` object.\n| **Important:** To properly set up and optimize `WebView`, apply all of the following recommendations to each `WebView` instance in your app. To help identify each web view, toggle the [\"highlight-all-webviews\"](//chromium.googlesource.com/chromium/src/+/main/android_webview/docs/developer-ui.md#flag-ui) flag in WebView DevTools to highlight the web views in your app with a yellow tint.\n\nEnable third-party cookies\n\nTo improve your user's ad experience and be consistent with Chrome's\n[cookie policy](//policies.google.com/technologies/cookies), enable third-party\ncookies on your `WebView` instance. \n\nJava \n\n CookieManager.getInstance().setAcceptThirdPartyCookies(webView, true);\n\nKotlin \n\n CookieManager.getInstance().setAcceptThirdPartyCookies(webView, true)\n\nWeb settings\n\nDefault `WebView` settings are not optimized for ads. Use the\n[`WebSettings`](//developer.android.com/reference/android/webkit/WebSettings)\nAPIs to configure your `WebView` for:\n\n- JavaScript\n- Access to local storage\n- Automatic video play\n\nJava \n\n import android.webkit.CookieManager;\n import android.webkit.WebView;\n\n public class MainActivity extends AppCompatActivity {\n private WebView webView;\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n setContentView(R.layout.activity_main);\n webView = findViewById(R.id.webview);\n\n // Let the web view accept third-party cookies.\n CookieManager.getInstance().setAcceptThirdPartyCookies(webView, true);\n // Let the web view use JavaScript.\n webView.getSettings().setJavaScriptEnabled(true);\n // Let the web view access local storage.\n webView.getSettings().setDomStorageEnabled(true);\n // Let HTML videos play automatically.\n webView.getSettings().setMediaPlaybackRequiresUserGesture(false);\n }\n }\n\nKotlin \n\n import android.webkit.CookieManager\n import android.webkit.WebView\n\n class MainActivity : AppCompatActivity() {\n lateinit var webView: WebView\n\n override fun onCreate(savedInstanceState: Bundle?) {\n super.onCreate(savedInstanceState)\n setContentView(R.layout.activity_main)\n webView = findViewById(R.id.webview)\n\n // Let the web view accept third-party cookies.\n CookieManager.getInstance().setAcceptThirdPartyCookies(webView, true)\n // Let the web view use JavaScript.\n webView.settings.javaScriptEnabled = true\n // Let the web view access local storage.\n webView.settings.domStorageEnabled = true\n // Let HTML videos play automatically.\n webView.settings.mediaPlaybackRequiresUserGesture = false\n }\n }\n\nLoad web view content\n\nCookies and page URLs are important for web view monetization and only function\nas expected when\n[`loadUrl()`](//developer.android.com/reference/android/webkit/WebView#loadUrl(java.lang.String,%20java.util.Map%3Cjava.lang.String,java.lang.String%3E)) is used with a network-based URL. For optimized\n`WebView` performance, load web content\ndirectly from network-based URLs. Avoid using [`WebViewAssetLoader`](//developer.android.com/reference/androidx/webkit/WebViewAssetLoader), loading\nassets from the device, or generating web content dynamically.\n\n\nJava \n\n import android.webkit.CookieManager;\n import android.webkit.WebView;\n\n public class MainActivity extends AppCompatActivity {\n private WebView webView;\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n setContentView(R.layout.activity_main);\n webView = findViewById(R.id.webview);\n\n // Let the web view accept third-party cookies.\n CookieManager.getInstance().setAcceptThirdPartyCookies(webView, true);\n // Let the web view use JavaScript.\n webView.getSettings().setJavaScriptEnabled(true);\n // Let the web view access local storage.\n webView.getSettings().setDomStorageEnabled(true);\n // Let HTML videos play automatically.\n webView.getSettings().setMediaPlaybackRequiresUserGesture(false);\n\n // Load the URL for optimized web view performance.\n webView.loadUrl(\"https://google.github.io/webview-ads/test/\");\n }\n }\n\nKotlin \n\n import android.webkit.CookieManager\n import android.webkit.WebView\n\n class MainActivity : AppCompatActivity() {\n lateinit var webView: WebView\n\n override fun onCreate(savedInstanceState: Bundle?) {\n super.onCreate(savedInstanceState)\n setContentView(R.layout.activity_main)\n webView = findViewById(R.id.webview)\n\n // Let the web view accept third-party cookies.\n CookieManager.getInstance().setAcceptThirdPartyCookies(webView, true)\n // Let the web view use JavaScript.\n webView.settings.javaScriptEnabled = true\n // Let the web view access local storage.\n webView.settings.domStorageEnabled = true\n // Let HTML videos play automatically.\n webView.settings.mediaPlaybackRequiresUserGesture = false\n\n // Load the URL for optimized web view performance.\n webView.loadUrl(\"https://google.github.io/webview-ads/test/\")\n }\n }\n\nTest the web view\n\nDuring app development, we recommend that you load this test URL: \n\n https://google.github.io/webview-ads/test/\n\nto verify these settings have the intended effect on ads. The test URL has\nsuccess criteria for a complete integration if the following are observed:\n\nWeb view settings\n\n- Third-party cookies work\n\n\u003c!-- --\u003e\n\n- First-party cookies work\n- JavaScript enabled\n\n\u003c!-- --\u003e\n\n- DOM storage enabled\n\nVideo ad\n\n- The video ad plays inline and does not open in the full screen built-in player\n- The video ad plays automatically without clicking the play button\n- The video ad is replayable\n\nAfter testing is complete, substitute the test URL with the URL the web view\nintends to load."]]