Select Page

python introduction

Download any version of Python3.x(eg.=3.2,3.7)

python 2.x is syntactically different from 3.xbut we will use python 3.x because it is better performance the 2.x

smiliar the Anoconda is framework which is give us set of tools and those tools are used in many ways  such as project etc.

now in which first talking about of Anaconda navigator and anaconda powershell

In anaconda powershell is a tool by which we install python package.

 

 

 

 

Android Media Player Code

package tts.indeed.com.mediaplayer;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.MediaController;
import android.widget.VideoView;

public class MainActivity extends Activity {

MediaController mediaController;
VideoView videoView;
Button openButton;
Uri current;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

videoView =(VideoView)findViewById(R.id.videoView1);
openButton = (Button) findViewById(R.id.openButton);

//Creating MediaController
mediaController= new MediaController(this);
mediaController.setAnchorView(videoView);

openButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent();

intent.setType(“video/*”);
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, “Video File to Play”), 0);
}
});
}

public void startPlayback()
{
//specify the location of media file
//Setting MediaController and URI, then starting the videoView
videoView.setMediaController(mediaController);
videoView.setVideoURI(current);
videoView.requestFocus();
videoView.start();
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
if (requestCode == 0)
{
if (resultCode == RESULT_OK)
{
Uri sourceUri = data.getData();
current = sourceUri;
startPlayback();
}
}
}

}

<?xml version=”1.0″ encoding=”utf-8″?>
<android.widget.RelativeLayout
xmlns:android=”http://schemas.android.com/apk/res/android”
xmlns:tools=”http://schemas.android.com/tools”
xmlns:app=”http://schemas.android.com/apk/res-auto”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
tools:context=”tts.indeed.com.mediaplayer.MainActivity”>

<VideoView
android:id=”@+id/videoView1″
android:layout_width=”match_parent”
android:layout_height=”300dp”
android:layout_below=”@+id/openButton”
android:layout_alignParentLeft=”true”
android:layout_alignParentStart=”true”
android:layout_marginTop=”50dp” />

<Button
android:id=”@+id/openButton”
android:layout_width=”match_parent”
android:layout_height=”wrap_content”
android:layout_alignParentLeft=”true”
android:layout_alignParentStart=”true”
android:layout_alignParentTop=”true”
android:layout_marginTop=”45dp”
android:text=”Open” />

</android.widget.RelativeLayout>

Click here for the files: https://drive.google.com/open?id=1g6p5YcCQptoypHMtIUxMbAFityHQX8iD

Splash Activity Code

Splash Activity will bring an image at the start of the application and after few seconds, it will jump to another activity.

Create a New Project

Go to File -> New -> New Project

Provide a Project name as Splash.

Select Empty Activity.

 

Add Splash Image

Go to Project Structure -> app -> res -> drawable

Right click on drawable -> New -> Batch Drawable Import

Select an Image from the pop-up window and click next/ok.

This will add the image to the drawable folder.

 

package com.example.splash;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;

public class MainActivity extends AppCompatActivity {
/** Duration of wait **/
private final int SPLASH_DISPLAY_LENGTH = 1000;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.activity_main);

/* New Handler to start the Menu-Activity
* and close this Splash-Screen after some seconds.*/
new Handler().postDelayed(new Runnable(){
@Override
public void run() {
/* Create an Intent that will start the Menu-Activity. */
Intent mainIntent = new Intent(MainActivity.this,Splash.class);
MainActivity.this.startActivity(mainIntent);
MainActivity.this.finish();
}
}, SPLASH_DISPLAY_LENGTH);
}

}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">

<ImageView android:id="@+id/splashscreen" android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:src="@drawable/splash"
android:layout_gravity="center"/>

<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hello World, splash"/>

</LinearLayout>

Android Intent Code

package com.indeedinspiring.androidworkshop_practice;

import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;

import static android.Manifest.permission.CALL_PHONE;
import static android.Manifest.permission.CAMERA;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

Button openbrower, opencall, opencontact, openCamera;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initView();
initListeners();

}

private void initListeners() {
openbrower.setOnClickListener(this);
opencall.setOnClickListener(this);
openCamera.setOnClickListener(this);
opencontact.setOnClickListener(this);
}

private void initView() {
openbrower = findViewById(R.id.openbrower);
opencall = findViewById(R.id.opencall);
openCamera = findViewById(R.id.opencamera);
opencontact = findViewById(R.id.opencontact);
}

@RequiresApi(api = Build.VERSION_CODES.M)
@Override
public void onClick(View view) {

switch (view.getId()) {

case R.id.openbrower:
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(“https://google.com”));
startActivity(intent);
break;

case R.id.opencall:
Intent i = new Intent(Intent.ACTION_CALL);
i.setData(Uri.parse(“tel:0612312312”));
if (ContextCompat.checkSelfPermission(getApplicationContext(), CALL_PHONE) == PackageManager.PERMISSION_GRANTED) {
startActivity(i);
} else {
requestPermissions(new String[]{CALL_PHONE}, 1);
}
break;

case R.id.opencontact:
Intent i1 = new Intent(Intent.ACTION_VIEW);
i1.setData(Uri.parse(“content://contacts/people/”));
startActivity(i1);
break;

case R.id.opencamera:
Intent intent1 = new Intent(“android.media.action.IMAGE_CAPTURE”);

if (ContextCompat.checkSelfPermission(getApplicationContext(), CAMERA) == PackageManager.PERMISSION_GRANTED) {
startActivity(intent1);
} else {
requestPermissions(new String[]{CAMERA}, 1);
}
startActivity(intent1);
break;

}
}
}

<?xml version=”1.0″ encoding=”utf-8″?>
<manifest xmlns:android=”http://schemas.android.com/apk/res/android”
package=”com.indeedinspiring.androidworkshop_practice”>

 

<uses-permission android:name=”android.permission.INTERNET”/>
<uses-permission android:name=”android.permission.CALL_PHONE”/>
<uses-permission android:name=”android.permission.CAMERA”/>

<application
android:allowBackup=”true”
android:icon=”@mipmap/ic_launcher”
android:label=”@string/app_name”
android:roundIcon=”@mipmap/ic_launcher_round”
android:supportsRtl=”true”
android:theme=”@style/AppTheme”>
<activity android:name=”.MainActivity”>
<intent-filter>
<action android:name=”android.intent.action.MAIN” />
<action android:name=”android.intent.action.VIEW”/>
<category android:name=”android.intent.category.LAUNCHER” />
</intent-filter>
</activity>
</application>

</manifest>

<?xml version=”1.0″ encoding=”utf-8″?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android=”http://schemas.android.com/apk/res/android”
xmlns:app=”http://schemas.android.com/apk/res-auto”
xmlns:tools=”http://schemas.android.com/tools”
android:id=”@+id/linearLayout”
android:layout_width=”match_parent”
android:layout_height=”match_parent”
tools:context=”.MainActivity”>

 

<Button
android:id=”@+id/openbrower”
android:layout_width=”0dp”
android:layout_height=”wrap_content”
android:layout_marginStart=”16dp”
android:layout_marginLeft=”16dp”
android:layout_marginEnd=”16dp”
android:layout_marginRight=”16dp”
android:text=”open Web”
app:layout_constraintBottom_toBottomOf=”parent”
app:layout_constraintEnd_toEndOf=”parent”
app:layout_constraintHorizontal_bias=”0.0″
app:layout_constraintStart_toStartOf=”parent”
app:layout_constraintTop_toTopOf=”parent”
app:layout_constraintVertical_bias=”0.077″ />

<Button
android:id=”@+id/opencall”
android:layout_width=”0dp”
android:layout_height=”wrap_content”
android:layout_marginStart=”16dp”
android:layout_marginLeft=”16dp”
android:layout_marginEnd=”16dp”
android:layout_marginRight=”16dp”
android:text=”open Call”
app:layout_constraintBottom_toBottomOf=”parent”
app:layout_constraintEnd_toEndOf=”parent”
app:layout_constraintHorizontal_bias=”0.0″
app:layout_constraintStart_toStartOf=”parent”
app:layout_constraintTop_toTopOf=”parent”
app:layout_constraintVertical_bias=”0.172″ />

<Button
android:id=”@+id/opencontact”
android:layout_width=”0dp”
android:layout_height=”wrap_content”
android:layout_marginStart=”16dp”
android:layout_marginLeft=”16dp”
android:layout_marginEnd=”16dp”
android:layout_marginRight=”16dp”
android:text=”Open Contact”
app:layout_constraintBottom_toBottomOf=”parent”
app:layout_constraintEnd_toEndOf=”parent”
app:layout_constraintHorizontal_bias=”0.0″
app:layout_constraintStart_toStartOf=”parent”
app:layout_constraintTop_toTopOf=”parent”
app:layout_constraintVertical_bias=”0.278″ />

<Button
android:id=”@+id/opencamera”
android:layout_width=”0dp”
android:layout_height=”wrap_content”
android:layout_marginStart=”16dp”
android:layout_marginLeft=”16dp”
android:layout_marginEnd=”16dp”
android:layout_marginRight=”16dp”
android:text=”Open Camera”
app:layout_constraintBottom_toBottomOf=”parent”
app:layout_constraintEnd_toEndOf=”parent”
app:layout_constraintHorizontal_bias=”0.0″
app:layout_constraintStart_toStartOf=”parent”
app:layout_constraintTop_toTopOf=”parent”
app:layout_constraintVertical_bias=”0.393″ />

 

</androidx.constraintlayout.widget.ConstraintLayout>

Click here for code files: https://drive.google.com/open?id=1m9cBwe9iFSpI47WL9KAuOfhCLEVJEJQI