رفتن به مطلب
مرجع رسمی سی‌پلاس‌پلاس ایران

kamran_14

کاربـــر عـــــادی
  • تعداد ارسال ها

    20
  • تاریخ عضویت

پست ها ارسال شده توسط kamran_14


  1. سلام

    من میخواهم دوباره مقدار و آیکن اکشن دوم را تغییر دهم. اما جواب نمی‌دهد. چرا؟

    Notification.Builder  notification = new Notification.Builder ( this )
                            .setSmallIcon ( R.drawable.ic_play )
                            .setContentTitle ( "madaraneh.mp3" )
                            .setContentText ( "madaraneh" )
                            .setContentIntent ( PendingIntent.getActivity ( this, 0, new Intent ( this, MusicPlayerActivity.class ), 0 ) )
                            .setOngoing ( true )
                            .addAction ( R.drawable.ic_rewind, "Rewind", rewindPending )
                            .addAction ( R.drawable.ic_play, "Play", playPending )
                            .addAction ( R.drawable.ic_forward, "Forward", forwardPending )
                            ;
                    NotificationManager notificationManager=(NotificationManager)getSystemService ( NOTIFICATION_SERVICE );
                    notification.build ().actions[1]=new Notification.Action (R.drawable.a1,"hhhhhhhh",playPending);
                    notificationManager.notify ( 12,notification.build () );

    کدی که برای ویرایش آیکن اکشن دوم نوشتم این است:

    notification.build ().actions[1]=new Notification.Action (R.drawable.a1,"hhhhhhhh",playPending);

     


  2. سلام

    بعضی از برندهای گوشی‌های تلفن همراه مثل سامسونگ اجازه دسترسی مستقیم به کارت حافظه رو نمی‌دهن و متد ()Environment.getExternalStorageDirectory فقط آدرس حافظه داخلی رو به ما می‌ده. . پس چطور باید در داخل کارت حافظه اطلاعاتمون رو ذخیره کنیم یا فایلی مثل mp3 رو بخونیم؟


  3. سلام

    خسته نباشید

    من برنامه ی videoview را در اندروید نوشتم هیچ مشکلی نداره و اجرا میشه و با تغییر جهت گوشی مقادیر از بین میره و از اول مقداردهی میشن حتی ویدیو از اول شروع میکند اما وقتی من این مشخصه را در manifest به Activity میدهم تمام مقادیر حفظ میشوند و ویدیو هم از اول شروع نمیکند چرا؟ من که مقادیر را در onSaveInstanceState ذخیره نکردم آیا این مشخصه کار onSaveInstanceState را انجام میدهد؟

    android:configChanges="screenSize|orientation"

     


  4. در در 16 مهر 1398 در 21:56، فرهاد شیری گفته است :

    یعنی با روتر (مثل مودم وای فای ) ویا هاب سوئیچ شبکه آدرس دهی کردید! وبه xamapp متصل میشید؟

    من با وای فای میرم اینترنت. و آی پی سیستم خودمو دادم به اندروید.


  5. در در 11 مهر 1398 در 23:33، فرهاد شیری گفته است :

    دوستت از چه روتری استفاده میکنه! وشما از چه روتری؟

    نحوه ارتباط تون با آدرس loop back روی سیستمی که xampp نصب هست به چه صورتی؟

      

    نحوه ارتباط با آدرس loop back را چطوری متوجه بشم؟


  6. در 2 ساعت قبل، فرهاد شیری گفته است :

    دوست گرامی!

    xamp در حقیقت یک بستر برای شبیه سازی http هست بدون نیاز به سرورهای میزبان اینترنت، بنابراین وقتی برنامه شما روی گوشی میخواد به وب سرویس های لوکال که با xamp ایجاد شده اند دسترسی داشته باشه! قطعا باید permission های مناسب را داشته باشه ولی هیچ ربطی به اینترنت نداره یعنی لزومی نداره که شما به اینترنت متصل باشید. حالا چرا باید دسترسی ها فعال باشه برای اینکه اندروید که نمیدونه شما دارید به یک سرور مجازی متصل میشید ویا یک سرور واقعی بنابراین طبق پروتکل های امنیتی خودش این دسترسی ها را لازم داره، در حقیقت لازم هم نداره که بدونه!

    تصور کنید که این سطح از امنیت وجود نداشت به راحتی هر کسی یک app درست میکرد میذاشت تو یک مارکت بعد میشد یک نرم افزار جاسوسی که راحت هرچی داشتید به سرقت میبرد.

    ممنون

    من و دوستم هر دو از یک ورژن اندروید استفاده میکنیم یعنی هر دو اندروید استودیو 3.4.2 را نصب کردیم. برنامه هامونو عین هم نوشتیم اما برا اون بدون اینترنت کار میکنه و پرمیشن مربوط به اینترنت نمیخواد ولی برنامه ی من باید برا دسترسی به سرور xampp به نت متصل باشم و پرمیشن هم میخواد. خیلی عجیبه برام


  7. سلام

    من چرا با android نمیتونم بدون اینترنت از xamp که در کامپیوتر خودم قرار داره اطلاعات رو دریافت کنم و از من permission میخواد برا اینترنت. در حالی که نباید بخواد. چون من لوکال کار میکنم

    ایراد از IP نمیتونه باشه؟ چرا وصل شدن به اینترنت اجباریه؟ در غیر اینصورت اطلاعاتی از سرور نشان داده نمیشود و پرمیشن میخواد

    من آی پی سیستم خودمو میدم

     
            String Url="http://192.168.43.3/shop/register.php";

     


  8. در ۱ ساعت قبل، فرهاد شیری گفته است :

    البته این متد getParams مربوط به کلاس volly هست که چه برای post چه برای get بایدoverride بشه!

    آقای شیری خیلی ممنون.

    پس میشه از نوشته ی شما فهمید که از سمت اندروید هم میتوان با متد GET به سرور اطلاعات فرستاد یعنی با کمک کلاس والی.

    آقای شیری ممنون میشم اگر مثال ساده ای بزنید که بتوان اطلاعات را با متد GET به سرور اطلاعات فرستاد. من در این کد بالا که فرستادم وقتی به جای POST از متد GET استفاده میکنم خطا میدهد. چرا؟ مگر هر دو کار ارسال اطلاعات به سرور را انجام نمیدهند؟ در حالی که در HTML وقتی میخواستیم با GET اطلاعات رو بفرستیم خودمان دستی در نوار آدرس نمینوشتیم. ببخشید که سوالمو دوباره پرسیدم چون از من خواسته شده در مورد GET تحقیق کنم


  9. چون میخواستم تفاوتشون رو عملی ببینم. ولی قبلا گفته شده بود استاندارد get,post در همه ی زبانهان یکسانه ولی در html میشد به سرور اطلاعات فرم رو فرستاد. خودش در آدرس بار نشون میداد و ما  کویری استرینقها رو ما نمینویشتیم


  10. سلام خسته نباشید

    این متد برای ثبت اطلاعات در سرور هست. مشکلی در این کد نیست. فقط چرا نمیشه با متد GET اطلاعات رو فرستاد؟ مگه متد GET برای ارسال اطلاعات نیست؟ من GET وقتی مینویسم عمل نمیکنه

     private void sendInfo(final String email, final String username, final String password, final String mobile)
        {
            String Url="http://192.168.43.3/shop/register.php";
            StringRequest stringRequest=new StringRequest ( Request.Method.POST, Url, new Response.Listener<String> () {
                @Override
                public void onResponse(String response) {
                    Log.i ( TAG, "onResponse: " );
    
                    try {
                        JSONObject jsonObject=new JSONObject ( response );
                        String resualt=jsonObject.getString ( "response" );
                        if (resualt.matches ( "ok" ))
                            Toast.makeText ( getContext (), "Successfully is Registred", Toast.LENGTH_SHORT ).show ();
                        else
                            Toast.makeText ( getContext (),"Faild",Toast.LENGTH_LONG ).show ();
                    } catch (JSONException e) {
                        e.printStackTrace ();
                    }
                }
            }, new Response.ErrorListener () {
                @Override
                public void onErrorResponse(VolleyError error) {
                    Toast.makeText ( getContext (), error+"", Toast.LENGTH_SHORT ).show ();
                }
            } ){
                @Override
                protected Map<String, String> getParams() throws AuthFailureError {
                    Map<String,String> params=new HashMap<> (  );
                    params.put ( "email",email );
                    params.put ( "username",username );
                    params.put ( "password",password );
                    params.put ( "mobile",mobile );
                    return params;
                }
            };
            stringRequest.setRetryPolicy (new DefaultRetryPolicy (10000,DefaultRetryPolicy.DEFAULT_MAX_RETRIES,DefaultRetryPolicy.DEFAULT_BACKOFF_MULT) );
            Volley.newRequestQueue ( getContext () ).add ( stringRequest );
        }

     


  11. سلام
    ببخشید سوالی داشتم.
    متد post  و get که در  html خواندیم با متد get و post اندروید فرق میکنه؟
    متد get و post در html هر دو برای ارسال اطلاعات بود. 
    فقط اگر با get ارسال میکردیم امنیت پایین بود به خاطر نمایش اطلاعات در آدرس بار مرورگر ولی سرعت ارسال اطلاعات با get زیاده
    و اگر با post ارسال کنیم امنیت بالاست چون در آدرس بار اطلاعات رو نشون نمیداد.

    در اندروید فرق میکنه؟ یعنی آیا برای ارسال اطلاعات میتوان از دو متد استفاده کرد؟


  12. سلام

    من کدها رو نوشتم ولی با این خطا مواجه میشوم.

    ایراد کدهای من چی میتونه باشه

    
    E/AndroidRuntime: FATAL EXCEPTION: main
        Process: com.example.shop, PID: 3607
        android.view.InflateException: Binary XML file line #24: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
        Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:761)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
            at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:861)
            at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
            at com.example.shop.Adapter.ProductAdapter.onCreateViewHolder(ProductAdapter.java:35)
            at com.example.shop.Adapter.ProductAdapter.onCreateViewHolder(ProductAdapter.java:19)
            at androidx.recyclerview.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:6794)
            at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5975)
            at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5858)
            at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5854)
            at androidx.recyclerview.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2230)
            at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1557)
            at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1517)
            at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:612)
            at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3924)
            at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:3641)
            at androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java:4194)
            at android.view.View.layout(View.java:17637)
            at android.view.ViewGroup.layout(ViewGroup.java:5575)
            at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1079)
            at android.view.View.layout(View.java:17637)
            at android.view.ViewGroup.layout(ViewGroup.java:5575)
            at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
            at android.view.View.layout(View.java:17637)
            at android.view.ViewGroup.layout(ViewGroup.java:5575)
            at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1741)
            at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)
            at android.widget.LinearLayout.onLayout(LinearLayout.java:1494)
            at android.view.View.layout(View.java:17637)
            at android.view.ViewGroup.layout(ViewGroup.java:5575)
            at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
            at android.view.View.layout(View.java:17637)
            at android.view.ViewGroup.layout(ViewGroup.java:5575)
            at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1741)
            at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)
            at android.widget.LinearLayout.onLayout(LinearLayout.java:1494)
            at android.view.View.layout(View.java:17637)
            at android.view.ViewGroup.layout(ViewGroup.java:5575)
            at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
            at com.android.internal.policy.DecorView.onLayout(DecorView.java:726)
            at android.view.View.layout(View.java:17637)
            at android.view.ViewGroup.layout(ViewGroup.java:5575)
            at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2346)
            at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2068)
            at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1254)
            at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6337)
            at android.view.Choreographer$CallbackRecord.run(Choreographer.java:874)
            at android.view.Choreographer.doCallbacks(Choreographer.java:686)
            at android.view.Choreographer.doFrame(Choreographer.java:621)
            at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:860)
            at android.os.Handler.handleCallback(Handler.java:751)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:154)
            at android.app.ActivityThread.main(ActivityThread.java:6119)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
    Application terminated.

    من در productActivity اینارو نوشتم:

    package com.example.shop.Adapter;
    import android.content.Context;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.view.ViewGroup;
    import android.widget.ImageView;
    import android.widget.TextView;
    import androidx.annotation.NonNull;
    import androidx.recyclerview.widget.RecyclerView;
    import com.example.shop.Models.Products;
    import com.example.shop.R;
    import java.util.ArrayList;
    import java.util.List;
    
    public class ProductAdapter extends RecyclerView.Adapter<ProductAdapter.ProductViewHolder>{
        private List<Products> products=new ArrayList<Products> (  );
        private Context context;
    
        public ProductAdapter(List<Products> products, Context context) {
            this.products = products;
            this.context = context;
        }
    
    
        @NonNull
        @Override
        public ProductViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
            View view=LayoutInflater.from ( parent.getContext () ).inflate ( R.layout.products_list_row,parent,false);//inflater.inflate (R.layout.products_list_row,parent);
            return new ProductViewHolder(view);
        }
    
        @Override
        public void onBindViewHolder(@NonNull ProductViewHolder holder, int position) {
            Products oP=products.get ( position );
            holder.txt_priceProduct.setText ( oP.getPriceProduct () );
            holder.txt_nameProduct.setText (oP.getNameProduct () );
            holder.img_imgProduct.setImageDrawable (oP.getImg_product () );
        }
    
        @Override
        public int getItemCount() {
            return products.size ();
        }
    
        public class ProductViewHolder extends RecyclerView.ViewHolder {
            public ImageView img_imgProduct;
            public TextView txt_nameProduct;
            public TextView txt_priceProduct;
            public ProductViewHolder(@NonNull View itemView) {
                super ( itemView );
                img_imgProduct=itemView.findViewById ( R.id.imgProduct );
                txt_nameProduct=itemView.findViewById ( R.id.nameProduct );
                txt_priceProduct=itemView.findViewById ( R.id.priceProduct );
            }
    
        }
    }

    و در productModel این کدهارو:

    package com.example.shop.Models;
    
    import android.graphics.drawable.Drawable;
    
    public class Products {
        private Drawable img_product;
        private String nameProduct;
        private String priceProduct;
    
        public Products(Drawable img_product, String nameProduct, String priceProduct) {
            this.img_product = img_product;
            this.nameProduct = nameProduct;
            this.priceProduct = priceProduct;
        }
    
        public Drawable getImg_product() {
            return img_product;
        }
    
        public void setImg_product(Drawable img_product) {
            this.img_product = img_product;
        }
    
        public String getNameProduct() {
            return nameProduct;
        }
    
        public void setNameProduct(String nameProduct) {
            this.nameProduct = nameProduct;
        }
    
        public String getPriceProduct() {
            return priceProduct;
        }
    
        public void setPriceProduct(String priceProduct) {
            this.priceProduct = priceProduct;
        }
    }
    

    و در productAdapter این کدها رو:

    package com.example.shop.Adapter;
    import android.content.Context;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.view.ViewGroup;
    import android.widget.ImageView;
    import android.widget.TextView;
    import androidx.annotation.NonNull;
    import androidx.recyclerview.widget.RecyclerView;
    import com.example.shop.Models.Products;
    import com.example.shop.R;
    import java.util.ArrayList;
    import java.util.List;
    
    public class ProductAdapter extends RecyclerView.Adapter<ProductAdapter.ProductViewHolder>{
        private List<Products> products=new ArrayList<Products> (  );
        private Context context;
    
        public ProductAdapter(List<Products> products, Context context) {
            this.products = products;
            this.context = context;
        }
    
    
        @NonNull
        @Override
        public ProductViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
            View view=LayoutInflater.from ( parent.getContext () ).inflate ( R.layout.products_list_row,parent,false);//inflater.inflate (R.layout.products_list_row,parent);
            return new ProductViewHolder(view);
        }
    
        @Override
        public void onBindViewHolder(@NonNull ProductViewHolder holder, int position) {
            Products oP=products.get ( position );
            holder.txt_priceProduct.setText ( oP.getPriceProduct () );
            holder.txt_nameProduct.setText (oP.getNameProduct () );
            holder.img_imgProduct.setImageDrawable (oP.getImg_product () );
        }
    
        @Override
        public int getItemCount() {
            return products.size ();
        }
    
        public class ProductViewHolder extends RecyclerView.ViewHolder {
            public ImageView img_imgProduct;
            public TextView txt_nameProduct;
            public TextView txt_priceProduct;
            public ProductViewHolder(@NonNull View itemView) {
                super ( itemView );
                img_imgProduct=itemView.findViewById ( R.id.imgProduct );
                txt_nameProduct=itemView.findViewById ( R.id.nameProduct );
                txt_priceProduct=itemView.findViewById ( R.id.priceProduct );
            }
    
        }
    }

    یک روزه که کلا من روی پیدا کردن خطا گذاشتم اما پیدا نکردم. لطفا کمکم کنید

×
×
  • جدید...