<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[windroid - Medium]]></title>
        <description><![CDATA[Learn to code &amp; code to learn - Medium]]></description>
        <link>https://medium.com/windroid?source=rss----7a5ba2663821---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>windroid - Medium</title>
            <link>https://medium.com/windroid?source=rss----7a5ba2663821---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 07:25:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/windroid" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Context in Android Application, What, When and Why]]></title>
            <link>https://medium.com/windroid/the-importance-of-context-in-the-life-of-android-application-developers-b8ce1606ca4?source=rss----7a5ba2663821---4</link>
            <guid isPermaLink="false">https://medium.com/p/b8ce1606ca4</guid>
            <category><![CDATA[context]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Ahmed Yehya]]></dc:creator>
            <pubDate>Mon, 29 May 2017 06:08:54 GMT</pubDate>
            <atom:updated>2017-12-04T05:48:11.861Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3p_nkLL82hhrN187bEaIKA.jpeg" /></figure><p>Context refers to the status, behavior, or process of an operation. If we apply that meaning to the parts of an application, we will define it as follows:<br>Is the behavior of the currently running part of the application, whether it is Object or otherwise, and it is a combination or entity that represents the working environment of the different data types. Context helps Activity, which is currently interacting with the other side of the Android system, such as local files, databases, the part for bringing Android classics (ready-made classes), services, and many more.</p><blockquote>The meaning of the context is simply to deal with the system to manage the various processes within the application.</blockquote><p>It is certain that you have passed the term Context while working on your applications and what you want to realize is that the context in Android is very important as you understand how to handle it so I will show you the right way to use it, The faulty memory of this object may lead to memory depletion in the application (Memory leaks)</p><p>There are several forms of context in Android that we will recognize, how to use them, and when to use one.</p><h4>Application Context</h4><p>This context belongs to the Lifecycle of an application. The Application context can be used if you want a context that is separate from the Activity context that is currently running or when you want to pass the Context to a range beyond the currently active activity It is called by</p><pre>getApplicationContext()</pre><p><strong>Example of use: </strong>If you want to create an object that works alone and is not specific to a specific activity and this object needs a Context, always pass the Application Context.</p><p><strong>Example of clarification:</strong> If you want to create a new class for a particular view that you want to create and you want to call Object of this class in more than one activity in this case you will pass it an Application Context.</p><p>If you pass Activity context it will cause Memory leak because in this case it will be the reference to Activity and the Activity will not be collected when it finishes its work in the Garbage collection. Also, if you want to call a specific library within the Activity, use the Application context.</p><h4>Activity Context</h4><p>This context works within the activity and is associated with the Lifecycle of an activity and is used if you see the Context pass in the scope of the activity only or if you want the Lifecycle of context to belong to the Lifecycle of current context,</p><p><strong>Example of use:</strong> If you want to create an object and its Lifecycle is dependent on the activity within it and not related to other activities</p><h4>getContext() in Content Provider</h4><p>This context is a form of Application Context and can be used the same use and is often used with the Content Provider and is accessed by</p><pre>getContext()</pre><h4>When do not we use getApplicationContext()?</h4><p>The Application Context is not, as some developers understand, a full context that supports all of the activity, Some of the things you are trying to use with Context will not work, especially those related to the GUI.</p><h4>Fixed base Apply it to use Context</h4><ul><li>In most cases, use the context that is available to you in the element you are working on.<br>-Reference Reference or the scope within which the element works. If only at the Activity level, use the Context. If at the Application level, use the Application Context so that the Lifecycle does not exceed the Lifecycle you want to use.<br>-If you want to use a specific object after the Lifecycle of activity is finished, use the Application Context.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b8ce1606ca4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/windroid/the-importance-of-context-in-the-life-of-android-application-developers-b8ce1606ca4">Context in Android Application, What, When and Why</a> was originally published in <a href="https://medium.com/windroid">windroid</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[أهمية الـ Context في حياة مطوري تطبيقات الأندرويد]]></title>
            <link>https://medium.com/windroid/%D8%A3%D9%87%D9%85%D9%8A%D8%A9-%D8%A7%D9%84%D9%80-context-%D9%81%D9%8A-%D8%AD%D9%8A%D8%A7%D8%A9-%D9%85%D8%B7%D9%88%D8%B1%D9%8A-%D8%AA%D8%B7%D8%A8%D9%8A%D9%82%D8%A7%D8%AA-%D8%A7%D9%84%D8%A3%D9%86%D8%AF%D8%B1%D9%88%D9%8A%D8%AF-15750e67ff62?source=rss----7a5ba2663821---4</link>
            <guid isPermaLink="false">https://medium.com/p/15750e67ff62</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[arabic]]></category>
            <dc:creator><![CDATA[Ahmed Yehya]]></dc:creator>
            <pubDate>Mon, 22 May 2017 10:49:45 GMT</pubDate>
            <atom:updated>2017-05-22T10:49:44.520Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Context </strong>تعني كلمة <br>في اللغة حالة أو سلوك أو طريقة سير عملية ما، فلو قمنا بتطبيق ذلك المعنى على أجزاء التطبيق سوف نقوم بتعريفه كالتالي: <br><strong>Object </strong>هو سلوك الجزء الذي يتم تشغيله حاليا من التطبيق سواء كان <br><strong>Context </strong>أو غير ذلك وهو عبارة عن تركيبة أو كيان يمثل بيئة العمل لأنواع البيانات المختلفة. تقوم ال <br><strong>Activity </strong>بمساعدة الـ <br><strong>،( Local files ) </strong>التي تعمل حاليا على التفاعل مع الجانب الآخر من نظام الأندرويد مثل الملفات الداخلية <br>،(services)قواعد البيانات، الجزء المتعلق بجلب الكلاسات الخاصة بنظام الأندرويد ( الكلاسات الجاهزة ، الخدمات وأشياء أخرى كثيرة.</p><blockquote>معنى الـ <strong>Context </strong>ببساطة هو التعامل مع النظام لتسيير العمليات المختلفة داخل التطبيق.</blockquote><p>من المؤكد أنك مطور لتطبيقات أندرويد بما أنك كلفت نفسك بقراءة هذه السطور ومن المؤكد أيضا أنك مررت بمصطلح الـ <strong>Context </strong>أثناء عملك على تطبيقاتك وما أريدك أن تدركه أن الـ <strong>Context </strong>في الأندرويد مهم للغاية كأهمية فهمك لطريقة التعامل معه لذلك سأوضح لك الطريقة الصحيحة لاستخدامه لأنه وببساطة استخدامك الخاطئ لهذا الشيئ قد يؤدي إلى استنفاذ الذاكرة في التطبيق<strong> ( Memory leaks )</strong></p><p>هناك أشكال متعددة للـ <strong>Context </strong>في الأندرويد سوف نتعرف عليها، طريقة استخدامها، ومتى نستخدم احداها</p><h4>Application Context</h4><p>هذا الـ Context ينتمي لدورة حياة التطبيق ككل <strong>( Lifecycle of an application )</strong> يمكن استخدام الـ <strong>( Application context )</strong> إذا كنت تريد context دورة حياته منفصلة عن الـ <strong>Context </strong>الخاص بالـ <strong>Activity </strong>التي تعمل حاليا أوعندما تريد تمرير ال <strong>Context </strong>لنطاق أبعد من الـ <strong>Activity </strong>التي تعمل حاليا ويتم استدعاءه عن طريق</p><pre>getApplicationContext()</pre><p>مثال للإستخدام : إذا كنت تريد إنشاء <strong>Object </strong>يعمل بمفرده وليس خاصا بـ <strong>Activity </strong>معينة وهذا الـ <strong>Object </strong>يحتاج إلى <strong>Context</strong>، قم دائما بتمرير ال <strong>Application Context</strong></p><p>مثال للتوضيح: إذا أردت إنشاء كلاس جديد لـ <strong>View </strong>معين تريد أن تنشأه وتريد استدعاء <strong>Object </strong>من هذا الكلاس في أكثر من <strong>Activity </strong>في هذه الحالة سوف تمرر له <strong>Application Context</strong>.</p><p>أما إذا قمت بتمرير <strong>Activity context</strong> سوف يؤدي إلى استنفاذ الذاكرة <strong>( Memory leak )</strong> لأنه في هذه الحالة سوف تكون مرجعيته للـ <strong>Activity </strong>ولن يتم تجميع الـ <strong>Activity </strong>عند انتهاء عملها في الـ <strong>Garbage collection</strong>. أيضا إذا أردت استدعاء مكتبة معينة داخل ال <strong>Activity </strong>قم باستخدام <strong>Application context</strong></p><h4>Activity Context</h4><p>هذه الـ <strong>Context </strong>تعمل داخل الـ <strong>Activity </strong>وتابعة للـ <strong>( Lifecycle of an activity )</strong> ويتم استخدامها في حال إذا أرت تمرير الـ <strong>Context </strong>في نطاق الـ <strong>Activity </strong>فقط أو في حال إذا أردت أن تكون ال <strong>( Lifecycle of context )</strong> تابعة لـ <strong>( Lifecycle of current context )</strong></p><p>مثال للإستخدام: إذا أردت إنشاء object وأن تكون الـ <strong>Lifecycle </strong>الخاصة به تابعة للـ <strong>Activity </strong>التي يعمل بداخلها وغير مرتبط ب <strong>Activities </strong>أخرى</p><h4>getContext() in Content Provider</h4><p>هذا الـ <strong>Context </strong>يعتبر شكل من أشكال الـ <strong>Application Context</strong> ويمكن أن يستخدم نفس استخدامه ويستخدم غالبا مع الـ <strong>Content Provider</strong> ويتم الوصول إليه عن طريق</p><pre>getContext()</pre><h4>متى لا نستخدم getApplicationContext؟</h4><p>- الـ <strong>( Application Context )</strong> ليست كما يفهمها البعض أنها <strong>Context</strong> كاملة تدعم كل ما تقوم به الـ <strong>Activity</strong>.<br>بعض الأشياء التي تحاول استخدام هذه الـ <strong>Context</strong> معها لن تصلح وخصوصا تلك المتعلقة بالـ <strong>GUI</strong>.</p><h4>قاعدة ثابتة قم بتطبيقها لاستخدام ال Context</h4><p>- في معظم الحالات استخدم الـ <strong>Context </strong>المتاحة لك في العنصر الذي تعمل عليه <strong>view</strong>, <strong>object</strong>…<br>- معرفة الـمرجع <strong>Reference </strong>أو النطاق الذي يعمل بداخله العنصر إذا كان على مستوى الـ <strong>Activity </strong>فقط قم باستخدام ال <strong>Context </strong>أما إذا كان على مستوى <strong>Application </strong>قم باستخدام <strong>Application Context</strong> حتى لا يتعدى الـ <strong>Lifecycle </strong>لهذا العنصر الـ <strong>Lifecycle </strong>الذي تريد استخدامه فيه <br>- في حال إذا كنت تريد استخدام <strong>Object </strong>معين بعد انتهاء الـ <strong>Lifecycle of activity</strong> قم باستخدام <strong>Application Context</strong></p><p>مصادر تم الإطلاع عليها قبل كتابة المقال:</p><p><a href="https://blog.mindorks.com/understanding-context-in-android-application-330913e32514">https://blog.mindorks.com/understanding-context-in-android-application-330913e32514</a></p><p><a href="http://www.simplecodestuffs.com/what-is-context-in-android/">http://www.simplecodestuffs.com/what-is-context-in-android/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=15750e67ff62" width="1" height="1" alt=""><hr><p><a href="https://medium.com/windroid/%D8%A3%D9%87%D9%85%D9%8A%D8%A9-%D8%A7%D9%84%D9%80-context-%D9%81%D9%8A-%D8%AD%D9%8A%D8%A7%D8%A9-%D9%85%D8%B7%D9%88%D8%B1%D9%8A-%D8%AA%D8%B7%D8%A8%D9%8A%D9%82%D8%A7%D8%AA-%D8%A7%D9%84%D8%A3%D9%86%D8%AF%D8%B1%D9%88%D9%8A%D8%AF-15750e67ff62">أهمية الـ Context في حياة مطوري تطبيقات الأندرويد</a> was originally published in <a href="https://medium.com/windroid">windroid</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>