Posts

Showing posts from February, 2017

Working with Next and Previous button for Array in Android

Image
MainActivity.java public class MainActivity extends AppCompatActivity { ListView listView ; List Songs = new ArrayList<>(); int Position , size , take ; public static final int MY_PERMISSION_READ_EXTERNAL_STORAGE = 1 ; String[] FavouriteActors ; @Override protected void onCreate(Bundle savedInstanceState) { super .onCreate(savedInstanceState); setContentView(R.layout. activity_main ); ShowSongList(); } public void ShowSongList(){ if (ContextCompat. checkSelfPermission ( this , Manifest.permission. READ_EXTERNAL_STORAGE )!= PackageManager. PERMISSION_GRANTED ){ if (ActivityCompat. shouldShowRequestPermissionRationale ( this ,Manifest.permission. READ_EXTERNAL_STORAGE )) { } else {ActivityCompat. requestPermissions ( this , new String[]{Manifest.permission. READ_EXTERNAL_STORAGE }, MY_PERMISSION_READ_EXTERNAL_STORAGE ); } } else { getSong...

Get AlbumArt and TrackName using ListView in Android

The below method shows to create list of AlbumArt and TrackName using ListView in Android. MainActivity.java public class MainActivity extends AppCompatActivity { List<String> Albumid=new ArrayList<>(); List<String> SongName=new ArrayList<>(); ListView listView; String Album_id[],SongNames[]; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); listView=(ListView)findViewById(R.id.lists); getAlbumArt(); if(Albumid!=null){ //converting List<String> to Arrays[] Album_id=Albumid.toArray(new String[Albumid.size()]);} else{ Log.d("Error","List string is null"); } getSong(); if(SongName!=null){ SongNames=SongName.toArray(new String[SongName.size()]); } else{ Log.d("Error","Songtrack is emp...

Create a simple MP3 player in Android

Image
In this post, you will learn to create a simple MP3 player in Android devices. Many interesting subjects in Android are involved while creating a simple MP3 player. Such as Cursor,ListView, Customized List View Adapter, SeekBar, Thread, MediaPlayer and Runtime permission for Marshmallow 6.0. I am going just write the codes here. This post is suitable for Basic and Intermediate level android programmers. MainActivity.java public class MainActivity extends AppCompatActivity implements MediaPlayer.OnPreparedListener { List SongPath = new ArrayList<>(); List SongNames = new ArrayList<>(); List AlbumNames = new ArrayList<>(); List AlbumDuration = new ArrayList<>(); List AlbumArts = new ArrayList<>(); public static final int MY_PERMISSION_REQUEST_READ_EXTERNAL_STORAGE = 1 ; String [] sngPath , sngName , AlbName , sngduration ; Integer[] AlbumImages ; static String TAG ; String SongPosition ; long mSongDur...