-
المساهمات
787 -
تاريخ الانضمام
-
تاريخ آخر زيارة
-
عدد الأيام التي تصدر بها
2
نوع المحتوى
ريادة الأعمال
البرمجة
التصميم
DevOps
التسويق والمبيعات
العمل الحر
البرامج والتطبيقات
آخر التحديثات
قصص نجاح
أسئلة وأجوبة
كتب
دورات
أجوبة بواسطة Flutter Dev
-
-
لما حاولت استخدم كودك بشكل التالي
public CharSequence getPageTitle(int position) { switch (position){ case 0: return "Students"; Resources res = getResources(); String text = res.getString(R.string.Tital); case 1:return "teacher"; default:return null; }
يظهر لدي الخطاء التالي :
Cannot resolve method 'getResources()'
-
1
-
-
بتاريخ On 7/14/2020 at 04:23 قال Mohamd Imran:
وعليكم السلام أخي @مروان مروان3
لم أفهم بالضبط المشكلة ,لكن إن أصبت فإنك تريد إستدعاء كلمة من ملف strings.xml إن كذلك يمكنك فعل ذلك من خلال فقط
Resources res = getResources(); String text = res.getString(R.string.students);
الأن المتغير text يحمل الكلمة يمكنك إستخدامه فيما ترغب
اهلا اخي
ارغب ب استخدامه في هذا الموقع بتحديد
getPageTitle(int position) { switch (position){ case 0:return "Students"; case 1:return "teacher"; default:return null; } }
كيف يمكنني ذلك؟لني جربت كذا طريقه ولم تنجح لدي
-
السلام عليكم ورحمة الله وبركاته
اريد معرفة طريقة تغير اسم tablelyout من ملف string استدعيه
الكود كالتالي
public class FregmantPageAdapter extends FragmentPagerAdapter { public FregmantPageAdapter(@NonNull FragmentManager fm) { super(fm); } @NonNull @Override public Fragment getItem(int position) { if (position==0) return new Table1(); else return new table2(); } @Override public int getCount() { return 2; } @Nullable @Override public CharSequence getPageTitle(int position) { switch (position){ case 0:return "Students"; case 1:return "teacher"; default:return null; } } }
بحيث اني استدعي كلمة الطلاب من ملف الاسترينج والأستاذ أيضا حاول ب طرق التي اعرفها ولم تنجح لدي كيف يمكن عمل ذلك بارك الله فيكم
-
1
-
-
بتاريخ On 11/7/2020 at 02:44 قال Mohamd Imran:
السلام عليكم أخي ,
لم أقصد إنه فارغ ب null بل الرابط الخاص بك بعد المشاركة يصبح هكذا
tteud84794m7245.000webhostapp.com/posts/null
لذلك المسار يتغير إلى
/posts/null وبهذا سيفتح في المتصفح لأن المسار يصبح غير صالح
من يومين وانا احاول افهم ما قصدته اخوي
الان فهمت لا اعلم لماذا ولكن المشكله التي ظهرت لديك ما تظهر لدي في هاتف اصدار انرويد 7 لذلك انا لم اعرف المشكلة
ولكن الان وانا اجربه على هاتف مختلفة اصدار الاندرويد p
واجهتني المشكلة
كل الشكر لك اخوي ربي يعطيك الف عافيه
-
اهلا اخي
لم افهم قصدك ب مسار null ولكن المشكلة ليست انه فارغ المشكلة ان لو قمت بعمل رابط للاكتفي a ورابط للاكتفي b الاثنين رح يتوجهو الى الاكتفتي a بعد الضغط عليهم وهذا الشي غلط بنسبه للاكتفتي b
-
1
-
-
-
1
-
-
بتاريخ الآن قال Mohamd Imran:
تمام أخي ,رح أتأكد من ذلك وأعلمك
تم عزيزي
-
اهلا عزيزي
عذرا على التاخر بس كنت اعمل نموذج للمشكلة حتى يسهل تشغيله
تم ارفاق النموذج جرب اعمل لو تكرمت مشاركه من الاكتفتي بثنيهم وشاهد الفرق الذي يحدث الاثنين سوف يتم توجيهم نحو اكتفتي A
-
1
-
-
بتاريخ الآن قال Mohamd Imran:
هل يمكنك إرفاق ملف المشروع مع أخر التعديلات التي قمت بها ,سأتفقد المشكلة
بتاكيد عزيزي دقائق فقط وسارفق المشروع
كل الشكر لك ي غالي
-
1
-
-
بتاريخ 13 دقائق مضت قال Mohamd Imran:
قم بإضافة
<intent-filter android:autoVerify="true">
حتى نخبر الأندرويد بأن النطاق لنا أي موثوق في الأكتيفتي الأول وقم بالتجربة ,وملاحظة أخرى : لا يهم من أي أكتيفيتي تقوم بالمشاركة لكن ما يهم هو الأكتيفيتي الذي وضعته هنا
<activity android:name=".Fragmant.MainActivityFargmain">
اصبح الكود كالتالي :
<!-- 1--> <activity android:name=".Fragmantmarket.MainActivityFargmainMarket"> <intent-filter android:autoVerify="true"> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="http" android:host="marketoman.000webhostapp.com" android:pathPrefix="/post" /> </intent-filter> </activity> <activity android:name=".Fragmant.MainActivityFargmain"> <intent-filter android:autoVerify="true"> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="http" android:host="marketoman.000webhostapp.com" android:path="/posts" /> </intent-filter> </activity>
ولكن بدون فائده الرابط لا يقرا الاكتفتي الثاني ابد وكانه ليس موجود بالاساس لا يزال يتوجه الى الاكتفتي الاول قمت بتجربة اشيا كثيره وبدون فائده
-
1
-
-
بتاريخ 5 دقائق مضت قال Mohamd Imran:
هذه بسبب خطأ في عنوان النطاق ,للتجربة قم بإزالة
<data android:scheme="https" android:host="marketoman.000webhostapp.com" android:path="/posts" />
وإبقي على واحدة فقط وقم بإرسال ذلك الرابط في الواتس اب ثم إضغط عليه وأعلمنى بالنتيجة ملاحظة الرابط الذي ستشاركه في الواتس اب يجب أن يكون هكذا
https://marketoman.000webhostapp.com/posts/134
أو بإستخدام http هكذا
http://marketoman.000webhostapp.com/posts/134
شاهد اخي انا قمت بتعديل الكود حسب ما اخبرتني واختصره الى واحد data فقط
اصبح الكود كامل كالتالي
<!-- 1--> <activity android:name=".Fragmantmarket.MainActivityFargmainMarket"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="http" android:host="marketoman.000webhostapp.com" android:pathPrefix="/post" /> </intent-filter> </activity> <!-- 2 --> <activity android:name=".Fragmant.MainActivityFargmain"> <intent-filter android:autoVerify="true"> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="http" android:host="marketoman.000webhostapp.com" android:path="/posts" /> </intent-filter> </activity>
هذا الكود الان لما اعمل مشاركة توجد نفس المشكلة فيه يروح الى اكتفتي واحد فقط الى هو الاكتفتي الاول
وفي حالة مت بتعديل الملف الى الشكل التالي : فسيفتح لدي المتصفح (التغير في path)
<!-- 1--> <activity android:name=".Fragmantmarket.MainActivityFargmainMarket"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="http" android:host="marketoman.000webhostapp.com" android:path="/post" /> </intent-filter> </activity> <!-- 2 --> <activity android:name=".Fragmant.MainActivityFargmain"> <intent-filter android:autoVerify="true"> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="http" android:host="marketoman.000webhostapp.com" android:path="/posts" /> </intent-filter> </activity>
حسب ما فهمت الان اول كود ميه ميه ولكن مشكلته لا يتوجه الى الصفحة الثانية او الاكتفتي الثاني مع اني اعمل مشاركة من الاكتفتي الثاني
وهذا شكل الكود من الواتساب
-
1
-
-
بتاريخ 3 دقائق مضت قال Mohamd Imran:
تمام قم بإضافة التالي الى
<intent-filter android:autoVerify="true">
<intent-filter android:autoVerify="true"> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="https" android:host="marketoman.000webhostapp.com" android:path="/posts" /> </intent-filter>
وقم بالتجربة
الان اصبح شكل الكود كالتالي عزيزي
<!-- 1--> <activity android:name=".Fragmantmarket.MainActivityFargmainMarket"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="http" android:host="marketoman.000webhostapp.com" android:pathPrefix="/post" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="https" android:host="marketoman.000webhostapp.com" android:pathPrefix="/post" /> </intent-filter> </activity> <!-- 2 --> <activity android:name=".Fragmant.MainActivityFargmain"> <intent-filter android:autoVerify="true"> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="https" android:host="marketoman.000webhostapp.com" android:path="/posts" /> </intent-filter> </activity>
ياخذني الى التطبيق ولكن مع نفس المشكلة الى الاكتفتي الاول
وبنسبة لو قمت بعمل path بدل pathPrefix في الاكتفتي الاول فلن ياخذني الى التطبيق بل الى المتصفح
-
1
-
-
بتاريخ الآن قال Mohamd Imran:
نعم الرابط الذي اقوم بمشاركته كالتالي
https://marketoman.000webhostapp.com/posts/134
ونوع الثاني يكون بدون اضافة ال s الى كلمة بوست
-
1
-
-
بتاريخ 2 دقائق مضت قال Mohamd Imran:
صحيح لكن أنت تستخدم pathPrefix وهذه يعني سيطابق أول جزء فقط لمطابقة نفس المسار بالضبط يجب أن تستخدم android:path
عملت الكود بشكل التالي :
<!-- 1--> <activity android:name=".Fragmantmarket.MainActivityFargmainMarket" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="http" android:host="marketoman.000webhostapp.com" android:path="/post" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="https" android:host="marketoman.000webhostapp.com" android:path="/post" /> </intent-filter> </activity> <!-- 2 --> <activity android:name=".Fragmant.MainActivityFargmain"> <intent-filter > <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="http" android:host="marketoman.000webhostapp.com" android:path="/posts" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="https" android:host="marketoman.000webhostapp.com" android:path="/posts" /> </intent-filter> </activity>
الان كلما ضغطت على الرابط ياخذني الى المتصفح وليس التطبيق
-
1
-
-
بتاريخ الآن قال Mohamd Imran:
بالتأكيد سيذهب إلى الأكتيفتي الأول لأن لديك نفس المسار لكلاهما هنا
android:pathPrefix="/posts"
الحل هو أعطي كل واحد منهما مسار مختلف عن الأخر وستحل المشكلة
انا عامل واحد كذا اخي
android:pathPrefix="/posts"
وثاني كذا
android:pathPrefix="/post"
الكلمات مختلفات
او كيف قصدك اعمل مسار مختلف؟
-
1
-
-
بتاريخ 3 دقائق مضت قال Mohamd Imran:
السلام عليكم أخي ,
أتوقع المشكلة لديك من أنك أضفت
<category android:name="android.intent.category.DEFAULT" />
لكلاهما فقط قم بإزالة
<category android:name="android.intent.category.DEFAULT" />
من الأكتفيفتي الثاني ويصبح هكذا ثم قم بالتجربة
<!-- 2 --> <activity android:name=".FragmantA.MainActivityA" > <intent-filter > <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="http" android:host="================" android:pathPrefix="/posts" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="https" android:host="===============" android:pathPrefix="/posts" /> </intent-filter> </activity>
وأيضا ملاحظة أخرى لا أعلم لماذا تستخدم data مرتين ؟ إن كنت تريد أن يفتح الرابط سواء http أو https فقط قم بإزالة ال scheme والأندرويد سيفتح النطاق بشكل تلقائي سواء http أو https لا يوجد داعي لوضعها مرتين
هلا بيك عزيزي @Mohamd Imran
قمت بحذف السطر التالي من الاكتفتي الثاني
<category android:name="android.intent.category.DEFAULT" />
ونجح الامر الان فعلا يظهر لي تطبيق واحد فقط ولكن توجد مشكلة واحده الان
الان مثلا انا عملت مشاركة من الاكتفتي الاول طبعا هو اكتفتي مختلف عن ثاني من ناحية التصميم وكل شي بعد دخول لينك من الاكتفتي الاول لو عملت مشاركة للاكتفتي الثاني رح يوديني لينك الى الاكتفتي الاول
طبعا هذا الشي غلط لنه حتى القول مختلفة والبيانات لا تظهر بهذا الشكل المفترض يذهب بي الا الاكتفتي الثاني
فما هو الحل عزيزي ؟
-
1
-
-
بتاريخ 3 ساعات قال مصطفى القباني:
تحياتي أستاذ مروان،
يمكنك تجربة إضافة هذا السطر في تعريف الActivity في ملف AndroidManifest.xml
android:launchMode = "singleTop"
أو:
android:launchMode = "singleInstance"
اهلا اخي
شكرا على ردك في البدايه
لم تنجح الطريقة عزيزي
للعلم المشكلة تحدث بعد اول تثبيت للتطبيق فقط ولو المستخدم اختار الاختيار الصحيح بعدها لا يظهر له السوال ولكن هذا خطاء المفترض من البدايه هو يشاهد خيار واحد فقط اشلون هو بيعرف هذا صح وهذا غلط
-
السلام عليكم ورحمة الله وبركاته
تحيه طيبه للجميع
لدي استفسار ي اخوان لو تكرمتو الي معه خلفيه عن الامر
انا استخدم deep linkin لمشاركة رابط الاكتفتي الى تطبيقات مختلفة مثل الواتساب
المشكلة انني ارغب بمشاركة 2 من الاكتفتي مختلفين
الان انا قادر على مشاركتهم ولكن لو افترضنا قمت بمشاركة activity A
لما اضغط على رابط رح يظهر لي اختيار تطبيقي حسنا هذا جيد وسياخذني الى activity A
ولكن الان لو عملت مشاركة الى activity B
لما احاول اضغط على الرابط رح يظهر تطبيقي مرتين من ضمن التطبيقات ولو قمت باختيار ما سبق اختياره لدى activity A سوف ياخذني الى اكتفتي activity A
فما هو الحل المتفرض لدى اختيار activity B يظهر لدي تطبيق واحد كما حدث لدى activity A وياخذني الى الاكتفتي المقصود
الكود الذي استخدمه كالتالي :
<!-- 1--> <activity android:name=".FragmanM.MainActivityM" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="http" android:host="============" android:pathPrefix="/post" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="https" android:host="===============" android:pathPrefix="/post" /> </intent-filter> </activity> <!-- 2 --> <activity android:name=".FragmantA.MainActivityA" > <intent-filter > <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="http" android:host="================" android:pathPrefix="/posts" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="https" android:host="===============" android:pathPrefix="/posts" /> </intent-filter> </activity>
اكتفتي M
Uri data =getActivity(). getIntent().getData(); if (data!= null) { try { post_id = data.getLastPathSegment().toString(); getPost(post_id); } catch (NumberFormatException e) { post_id=null; } } Bundle bundle = getActivity().getIntent().getExtras(); if (bundle !=null){ if(post_id==null){ post_id =bundle.getString("mid"); getPost(post_id); } }
اكتفتي A
Uri data =getActivity(). getIntent().getData(); if (data!= null) { try { posts_id = data.getLastPathSegment().toString(); getPost(posts_id); } catch (NumberFormatException e) { posts_id=null; } } Bundle bundle = getActivity().getIntent().getExtras(); if (bundle !=null){ if(posts_id==null){ posts_id =bundle.getString("moid"); getPost(posts_id); } }
صورة توضيحية هذا لدى اختيار اول اكتفتي ما يظهر وهو صحيح طبعا
وهذا ما يظهر في الرابط الثاني وهو خطاء طبعا يجب ان يشاهد المستخدم تطبيقي لمرة واحد وان يكون الاكتفتي المستهدف
ياليت اذا احد يعرف الحل يساعدنا مشكور
-
1
-
-
بتاريخ On 28/6/2020 at 04:39 قال ماجد قطوسة:
هلا بيك اخي
قمت بتابع خطواتك + تغير المتصفح ونجح الامر يبدو ان الجوجل كروم يستعدي بيانات لوكل هوست
-
1
-
-
السلام عليكم ورحمة الله وبركاته تحيه طيبه للجميع
استفسار لو تكرمتو
كيف يمكن عمل مشاركة للاكتفتي
انا الان عامل مشاركة لصورة من الاكتفتي مثلا او نص واريد ارسل رابط للمستخدم لدى الصوره بحيث لو ضغط على الرابط رح يتوجه الى اكتفتي الصورة او المشاركة التي توجد بها الصوره التي تم مشاركتها
مثال على الكود المستخدم الان:
String text = "Look at my awesome picture"; Uri pictureUri = Uri.parse("file://my_picture"); Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_TEXT, text); shareIntent.putExtra(Intent.EXTRA_STREAM, imageUri); shareIntent.setType("image/*"); shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); startActivity(Intent.createChooser(shareIntent, "Share images..."));
كيف يمكن التعديل عليه بحيث اصبح قادر على مشاركة رابط الاكتفتي الذي تم عمل مشاركة منه
-
1
-
-
بتاريخ 3 دقائق مضت قال Mohamd Imran:
ولا يهمك أخي ,هل يمكنك مشاركة ملف التطبيق كامل ,حتى أتفحصه ربما سبب المشكلة خطأ في مكان أخر
تم اخي دقائق فقط
رح اعمل نسخه مصغره من المشروع وارفقها
-
1
-
-
بتاريخ 6 دقائق مضت قال Mohamd Imran:
سبب المشكلة هو من الهاتف الذي تقوم بتشغيل التطبيق عليه يملك إصدار أندرويد عالي مثل ٩ او ١٠ ,الخ.. وفي هذه الإصدارات يجب الحصول على الصلاحيات من التطبيق الذي تريد المشاركة علية أقصد في حالتك هو الواتس أب يوجد خيارات أول واحد هو حاول تجربة التطبيق على جهاز ذو إصدار أندرويد منخفض مثل ٥ أو ٦ الخيار الثاني هو جرب إضافة إسم الباكيج الخاص بالواتس أب إلى الفنشكن هكذا بشكل يدوي
private void shareImage( ) { BitmapDrawable bitmapDrawable = ((BitmapDrawable) prImg.getDrawable()); Bitmap myimg = bitmapDrawable .getBitmap(); String bitmapPath = MediaStore.Images.Media.insertImage(getActivity().getContentResolver(), myimg,"some title", null); Uri bitmapUri = Uri.parse(bitmapPath); Intent shareIntent=new Intent(Intent.ACTION_SEND); String packageName = "com.whatsapp"; this.grantUriPermission(packageName,bitmapUri,Intent.FLAG_GRANT_READ_URI_PERMISSION); shareIntent.setType("image/*"); shareIntent.putExtra(Intent.EXTRA_STREAM, bitmapUri); startActivity(Intent.createChooser(shareIntent,"Share Image")); }
وقم بالتجربة مرة أخرى إن لم ينفع أيضاً ,تفقد صلاحيات الواتس أب
العذر وسموحه اخي تعبتك معي
بنسبه ل اصدار نظام التشغيل هو 7.0 الذي اقوم بالاختبار عليه ليس جديد
وبنسبه ل اضافة باكينج واتساب المشكلة تحدث بمجرد ان اضغط على زر المشاركة يعني شاشة اختيار التطبيقات التي سوف اشارك الصوره معها لا تظهر بالاساس الكرش يحدث قبل ذلك
-
1
-
-
بتاريخ 5 دقائق مضت قال Mohamd Imran:
هذه مشكلة نظام أندرويد أو بالتحديد من ال SDK قم بإضافة الميثود التالية فوق الفنكشنshareImage الخاص بنا
public void grantPermissions(Context context, Intent intent, Uri uri, boolean writeAble) { int flag = Intent.FLAG_GRANT_READ_URI_PERMISSION; if (writeAble) { flag |= Intent.FLAG_GRANT_WRITE_URI_PERMISSION; } intent.addFlags(flag); List<ResolveInfo> resInfoList = context.getPackageManager() .queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); for (ResolveInfo resolveInfo : resInfoList) { String packageName = resolveInfo.activityInfo.packageName; context.grantUriPermission(packageName, uri, flag); } }
ثم نقوم بإضافتها في الفنكشن هكذا
// Share image private void shareImage( ) { BitmapDrawable bitmapDrawable = ((BitmapDrawable) imageviews.getDrawable()); Bitmap myimg = bitmapDrawable .getBitmap(); String bitmapPath = Images.Media.insertImage(getContentResolver(), myimg,"some title", null); Uri bitmapUri = Uri.parse(bitmapPath); Intent shareIntent=new Intent(Intent.ACTION_SEND); grantPermissions(this,shareIntent,bitmapUri,true); shareIntent.setType("image/*"); shareIntent.putExtra(Intent.EXTRA_STREAM, bitmapUri); startActivity(Intent.createChooser(shareIntent,"Share Image")); }
لا تزال المشكلة مستمره غريبه صراحه الامر
الكود كامل الان كالتالي :مع العلم اني استخدم الكود في Fragment
shareImage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { shareImage(); } }); return rootView; } public void grantPermissions(Context context, Intent intent, Uri uri, boolean writeAble) { int flag = Intent.FLAG_GRANT_READ_URI_PERMISSION; if (writeAble) { flag |= Intent.FLAG_GRANT_WRITE_URI_PERMISSION; } intent.addFlags(flag); List<ResolveInfo> resInfoList = context.getPackageManager() .queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); for (ResolveInfo resolveInfo : resInfoList) { String packageName = resolveInfo.activityInfo.packageName; context.grantUriPermission(packageName, uri, flag); } } private void shareImage( ) { BitmapDrawable bitmapDrawable = ((BitmapDrawable) prImg.getDrawable()); Bitmap myimg = bitmapDrawable .getBitmap(); String bitmapPath = MediaStore.Images.Media.insertImage(getActivity().getContentResolver(), myimg,"some title", null); Uri bitmapUri = Uri.parse(bitmapPath); Intent shareIntent=new Intent(Intent.ACTION_SEND); grantPermissions(getContext(),shareIntent,bitmapUri,true); shareIntent.setType("image/*"); shareIntent.putExtra(Intent.EXTRA_STREAM, bitmapUri); startActivity(Intent.createChooser(shareIntent,"Share Image")); }
-
1
-
-
بتاريخ 5 دقائق مضت قال Mohamd Imran:
تمام قم بإضافة الصلاحيات من خلال ال intent في الفنكشن هكذا
// Share image private void shareImage( ) { BitmapDrawable bitmapDrawable = ((BitmapDrawable) imageviews.getDrawable()); Bitmap myimg = bitmapDrawable .getBitmap(); String bitmapPath = Images.Media.insertImage(getContentResolver(), myimg,"some title", null); Uri bitmapUri = Uri.parse(bitmapPath); Intent shareIntent=new Intent(Intent.ACTION_SEND); shareIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); shareIntent.setType("image/*"); shareIntent.putExtra(Intent.EXTRA_STREAM, bitmapUri); startActivity(Intent.createChooser(shareIntent,"Share Image")); }
لاحظ
shareIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
نفس المشكلة عزيزي
الكراش كالتالي:
2020-07-02 00:31:48.100 26184-26184/com.example.myapplication E/MediaStore: Failed to insert image java.lang.SecurityException: Permission Denial: writing com.android.providers.media.MediaProvider uri content://media/external/images/media from pid=26184, uid=10315 requires android.permission.WRITE_EXTERNAL_STORAGE, or grantUriPermission()
هذا شكل الكود كامل لدي الان :
private void shareImage( ) { BitmapDrawable bitmapDrawable = ((BitmapDrawable) prImg.getDrawable()); Bitmap myimg = bitmapDrawable .getBitmap(); String bitmapPath = MediaStore.Images.Media.insertImage(getActivity().getContentResolver(), myimg,"some title", null); Uri bitmapUri = Uri.parse(bitmapPath); Intent shareIntent=new Intent(Intent.ACTION_SEND); shareIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); shareIntent.setType("image/*"); shareIntent.putExtra(Intent.EXTRA_STREAM, bitmapUri); startActivity(Intent.createChooser(shareIntent,"Share Image")); }
-
1
-
كيفية استدعاء اسم الجدول من ملف string
في أسئلة البرمجة
نشر
هلا بيك عزيزي
نفس المشكلة السابقه