for network security config
add this in manifest file
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
inside the application tag in the manfiest file
android:networkSecurityConfig="@xml/network_security_config"
Create a res/xml/network_security_config.xml file:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">commondatastorage.googleapis.com</domain>
</domain-config>
</network-security-config>
in the java file set video uri to video
videoView = findViewById(R.id.videoView);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
videoView.setMediaController(mediaController);
videoView.setVideoURI((Uri.parse("http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4")));
videoView.start();
add retrofit to the app
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
in Api package create ApiClient
public class ApiClient {
public static Retrofit RETROFIT = null;
public static Retrofit getclient(){
if(RETROFIT==null) {
OkHttpClient okHttpClient = new OkHttpClient.Builder().build();
Gson gson = new GsonBuilder().create();
RETROFIT = new Retrofit.Builder()
.baseUrl("https://soft-fix.in/sprintkart/")
.client(okHttpClient)
.addConverterFactory(GsonConverterFactory.create(gson)).build();
}
return RETROFIT;
}
}
ApiInterface
public interface ApiInterface {
@FormUrlEncoded
@POST("api/v1/auth/login")
Call<Login_Responce> loginverification(@Field("email") String email, @Field("password") String password);
@GET("api/v1/categories")
Call<Get_Main_Categories> fetchmaincategories();
}
// i n the activity
ApiInterface apiInterface;
Retrofit retrofit = com.moneyhawk.videobaseapp.api.ApiClient.getclient();
apiInterface = retrofit.create(com.moneyhawk.videobaseapp.api.ApiInterface.class);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
videoView.setMediaController(mediaController);
// videoView.setVideoURI((Uri.parse("http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4")));
videoView.setVideoURI((Uri.parse("https://codingsansar.com/api/android2/android/uploads/2839596-hd_1280_720_30fps.mp4")));
videoView.start();
public void gethorizontalscrollitem() {
apiInterface.fetchmaincategories().enqueue(new Callback<ListModel>() {
@Override
public void onResponse(Call<ListModel> call, Response<ListModel> response) {
try {
if (response != null) {
Log.e("apihit","api responce: "+ response.body().getMessage());
if (response.body().isStatus()==true) {
// setadapter(response.body().getData());
// setadapterhardware(response.body().getData());
// GalleryList(new Gson().toJson(response.body()).toString()+"");
} else {
Toast.makeText(VideoActivity.this, response.body().getMessage(), Toast.LENGTH_SHORT).show();
}
}
} catch (Exception e) {
Log.e("exp", e.getLocalizedMessage());
}
}
@Override
public void onFailure(Call<ListModel> call, Throwable t) {
Log.e("failure", t.getLocalizedMessage());
}
});
//
}
// shared pref
public enum ApplicationConstant {
INSTANCE;
public String username = "username";
public String useremail = "useremail";
public String userpwd = "userpwd";
// public String prefNamePref = "prefNamePref";
public String prefNamePref = "MyPrefsFile";
}
SharedPreferences.Editor editor = getSharedPreferences(ApplicationConstant.INSTANCE.prefNamePref, MODE_PRIVATE).edit();
editor.putString("username",username);
editor.putString("useremail",useremail);
Log.d("userid","user id" +userid );
editor.apply();
SharedPreferences prefs = getSharedPreferences(ApplicationConstant.INSTANCE.prefNamePref, MODE_PRIVATE);
myusername = prefs.getString("username"," ");
myuseremail = prefs.getString("useremail","");
firebase databsae
implementation 'com.google.firebase:firebase-auth:16.0.5'
implementation 'com.google.firebase:firebase-database:16.0.4'
implementation 'com.google.firebase:firebase-storage:19.1.1'