Skip to main content

Posts

Diving into Kotlin Multiplatform: A Developer's First Look

  Hey fellow coders! Let's talk about a problem we've all faced. You're building an app for both Android and iOS . You write your networking layer, your data models, and all your business logic in Kotlin for Android. Then, you switch over to Xcode and... write the exact same networking layer, the exact same data models, and the exact same business logic in Swift . It's tedious. It's a maintenance nightmare. And it feels... wrong. What if you could write all that core logic just once ? Enter Kotlin Multiplatform (KMP) . So, what exactly IS KMP? In the simplest terms, KMP is a technology from JetBrains that lets you share code between different platforms—like Android, iOS, Web , and Desktop . But here's the most important part to understand right away: KMP is for sharing logic, not the UI . Think of it like this: your app has a "brain" (the business logic, data handling, and network calls) and a "face" (the user interface). KMP lets you bui...

How to set image button click effect ?

I have one simple solution: using that, you can set the default press effect to the button. // Create button and add event Button addImageView = (Button) bottomView.findViewById(R.id. addImage ); addImageView.setOnClickListener( new OnClickListener () { @Override public void onClick(View v) { // click event } }); //Using this code set touch listener addImageView.setOnTouchListener( touchEffect ); //touch listner OnTouchListener touchEffect = new OnTouchListener() {         public boolean onTouch(View v, MotionEvent event) {             switch (event.getAction()) {                 case MotionEvent. ACTION_DOWN : {                     v.getBackground().setColorFilter(0xe0f47521,PorterDuff.Mode. SRC_ATOP );                     v....

Date compare in java android

private boolean checkDateLimit() { long CurrentDateInMilisecond = System.currentTimeMillis(); // Date 1 long Date1InMilisecond = Date1.getTimeInMillis(); //Date2 if (CurrentDateInMilisecond <= Date1InMilisecond) { return true; } else { return false; } } /* Date1 and Date2 convert into milisecond check its value. /*

Date picker android

Button toDate = (Button) findViewById(R.id.doc_dateto); toDate.setOnClickListener(new OnClickListener() { private int month; private int year; private int day; @Override public void onClick(View v) { OnDateSetListener datePickerListener = null; datePickerListener = new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker view, int selectedYear, int selectedMonth, int selectedDay) { year = selectedYear; month = selectedMonth; day = selectedDay; Calendar c = Calendar.getInstance(); c.set(year, month, day); toDate.setText(c.getTime().toGMTString()); } }; final Calendar c = Calendar.getInstance(); year = c.get(Calendar.YEAR); month = c.get(Calendar.MONTH); day = c.get(Calendar.DAY_OF_MONTH); DatePickerDialog datePicker = new DatePickerDialog( SUP101SampleActivity.this, datePickerListener, year, mo...

Simple and sort Listview example (Android)

private View getChapterLayout() { ListView listView = new ListView(this); listView.setAdapter(new BaseAdapter() { public int getCount() { return chapterdata.size(); } public Object getItem(int position) { return chapterdata.get(position); } public long getItemId(int addressList) { return 0; } public View getView(int position, View convertView, ViewGroup parent) { inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = inflater.inflate(R.layout.button_chapter, null); TextView textview = (TextView) convertView .findViewById(R.id.button); textview.setText(chapterdata.get(position).getName()); return convertView; } }); return listView; } // chapterdata is an arrayList // Add Event to each Row  listView.setOnItemClickListener(new OnItemClickListener() { public void onItemClic...

How to set costume fonts in android

1. create  assets/fonts/  and put your TTF files in there: 2.set view's properties. TextView tv =( TextView ) findViewById ( R . id . custom );   Typeface face = Typeface . createFromAsset ( getAssets (), "fonts/ARIAL.ttf" );   tv . setTypeface ( face );

Google Map Api key for Android, JDK6 and JDK 7. and Android Invalid Map API Key

How to get Google Api key? 1. Getting the MD5 Fingerprint of the SDK Debug Certificate   open commnad prompt. Using cd command reach java bin folder ex. cd  C:\Program Files\Java\jdk1.7.0_04\bin> 2. Type following command. For windows  JDK 1.7 keytool -v -list -alias androiddebugkey -keystore "C:\Users\virens\.android\debug.keystore" -storepass android -keypass android jdk 1.6 keytool -list -alias androiddebugkey -keystore "C:\Users\virens\.android\debug.keystore" -storepass android -keypass android other platform Windows Vista:  C:\Users\<user>\.android\debug.keystore Windows XP:  C:\Documents and Settings\<user>\.android\debug.keystore OS X and Linux:  ~/.android/debug.keystore 3.Open below url and create account.Paste that md5 signature.  http://code.google.com/android/maps-api-signup.html Note :  Android Invalid Map API Key I'm willing to bet that you ha...