In Android,When I tried to load the Ad in Admob and there is no internet connection the code reaches onRewardedVideoAdFailedToLoad() and after sometime say 30 sec the app force closes with the below mentioned error.
I hope this is not the null pointer exception that I can handle. It is happening in the SDK I guess. Please let me know how to resolve this.
Code
private void setRewardedVideo() {
rewardedVideoAd = MobileAds.getRewardedVideoAdInstance(this);
rewardedVideoAd.setUserId(REWARD);
AdRequest adRequest = new AdRequest.Builder().build();
rewardedVideoAd.loadAd(AD_UNIT_ID_REWARDED_VIDEO_AD, adRequest);
rewardedVideoAd.setRewardedVideoAdListener(new RewardedVideoAdListener() {
#Override
public void onRewardedVideoAdLoaded() {
System.out.println("onRewardedVideoAdLoaded()");
if (rewardedVideoAd.isLoaded()) {
rewardedVideoAd.show();
}
}
#Override
public void onRewardedVideoAdOpened() {
System.out.println("onRewardedVideoAdOpened()");
}
#Override
public void onRewardedVideoStarted() {
System.out.println("onRewardedVideoStarted()");
}
#Override
public void onRewardedVideoAdClosed() {
System.out.println("onRewardedVideoAdClosed()");
}
#Override
public void onRewarded(RewardItem rewardItem) {
System.out.println("onRewarded()");
}
#Override
public void onRewardedVideoAdLeftApplication() {
System.out.println("onRewardedVideoAdLeftApplication()");
}
#Override
public void onRewardedVideoAdFailedToLoad(int i) {
System.out.println("onRewardedVideoAdFailedToLoad()");
}
});
}
Logcat
java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.ViewParent com.google.android.gms.ads.internal.au.getParent()' on a null object reference
at com.google.android.gms.ads.internal.a.b(SourceFile:513)
at com.google.android.gms.ads.internal.b.b(SourceFile:318)
at com.google.android.gms.ads.internal.a.c(SourceFile:520)
at com.google.android.gms.ads.internal.aq.run(SourceFile:64)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5296)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Ensure the user has connectivity before even trying to load the ads, there may be some deeper issue with AdMob that forces this NPE despite no internet.
private void setRewardedVideo() {
if (!isNetworkAvailable()) {
// Log no internet
return;
}
rewardedVideoAd = MobileAds.getRewardedVideoAdInstance(this);
rewardedVideoAd.setUserId(REWARD);
....
}
It may even make sense to ensure user has internet before trying to use adMob incase it is something with their library that is causing the issue. See this answer for that.
Related
I'm trying to run a function that requires passing it a screen capture. When I run this from the main activity, I can run the code like this:
SendScreenFunction(getWindow().getDecorView().getRootView(), getApplicationContext());
I'm not trying to call this function from a service and I can't access the getWindow() function because it requires an activity (which isn't available in the service). I was looking around online and someone suggested a function to get the activity so I can use the function. My current code looks like this:
public class ASTasks extends Service {
// This method run only one time. At the first time of service created and running
#Override
public void onCreate() {
HandlerThread thread = new HandlerThread("ServiceStartArguments",
Process.THREAD_PRIORITY_BACKGROUND);
thread.start();
Log.d("onCreate()", "After service created");
}
#Override
public int onStartCommand(Intent intent, int flags, int startId) {
Toast.makeText(this, "Entered Timer!", Toast.LENGTH_SHORT).show();
Activity main_activity = getActivity(getApplicationContext());
try {
Log.i("Services", "Before crash");
SendScreenFunction(main_activity.getWindow().getDecorView().getRootView(), getApplicationContext());
Log.i("Services", "After crash");
} catch (IOException e) {
e.printStackTrace();
}
return START_STICKY;
}
#Override
public IBinder onBind(Intent intent) {
// We don't provide binding
return null;
}
public void SendScreenFunction(View view, Context context){
// Function goes here
}
public static Activity getActivity(Context context) {
if (context == null) return null;
if (context instanceof Activity) return (Activity) context;
if (context instanceof ContextWrapper) return getActivity(((ContextWrapper)context).getBaseContext());
return null;
}
}
Unfortunately, that solution doesn't seem to work and it's crashing. The Logcat error is shown below:
Process: com.example.ASservice:remote, PID: 15966
java.lang.RuntimeException: Unable to start service com.example.ASservice.ASTasks#6e7fed5 with Intent { cmp=com.example.ASservice/.ASTasks }: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.Window android.app.Activity.getWindow()' on a null object reference
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:5110)
at android.app.ActivityThread.access$2100(ActivityThread.java:310)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2319)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.app.ActivityThread.main(ActivityThread.java:8680)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:567)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.Window android.app.Activity.getWindow()' on a null object reference
at com.example.ASservice.ASTasks.onStartCommand(ASTasks.java:41)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:5092)
at android.app.ActivityThread.access$2100(ActivityThread.java:310)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2319)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.app.ActivityThread.main(ActivityThread.java:8680)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:567)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
Any ideas on the best way to take the screen capture from within the service (or even a way to pass a flag back to main to process it there)?
Any suggestions would be greatly appreciated. Thanks!
I went to sleep yesterday with my app working and today when I tried to run it won't start at all. As soon as I try to open it crashes with a java.lang.IllegalStateException. I've gone several commits back in my code just to rule out it was something I did recently and still. This makes no sense, how can an app just stop working over night? I've looked for the error in the internet and there is not a lot of useful information about it. Is this really an odd error?
Here's the complete stack trace:
E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.IllegalStateException: AssetManager has been finalized!
at android.os.Parcel.readException(Parcel.java:1439)
at android.os.Parcel.readException(Parcel.java:1385)
at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1947)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1419)
at android.app.Activity.startActivityForResult(Activity.java:3390)
at android.app.Activity.startActivity(Activity.java:3583)
at com.android.launcher2.Launcher.startActivity(Launcher.java:2442)
at com.android.launcher2.Launcher.startActivitySafely(Launcher.java:2469)
at com.android.launcher2.AppsCustomizePagedView.onClick(AppsCustomizePagedView.java:584)
at android.view.View.performClick(View.java:4240)
at android.view.View$PerformClick.run(View.java:17721)
at android.os.Handler.handleCallback(Handler.java:730)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5136)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Since like I said it doesn't seem to be anything that I did I'm not sure what code to post. But given that the app crashes on start here's the code for the two main classes that are supposed to start first:
App
public class App extends Application {
private static App instance;
private static final String TAG = "Starter";
#Override
public void onCreate() {
super.onCreate();
instance = this;
// Enable Local Datastore.
Parse.enableLocalDatastore(this);
//TODO: Register subclasses
// ParseObject.registerSubclass(Challenge.class);
//Parse server
Log.d(TAG, "Initializing Parse");
Parse.initialize(new Parse.Configuration.Builder(this)
.applicationId(getString(R.string.parse_app_id))
.clientKey(getString(R.string.parse_client_key))
.server(getString(R.string.server_address)).build()
);
//Facebook
if (AccessToken.getCurrentAccessToken() == null)
ParseFacebookUtils.initialize(this);
ParseUser.enableAutomaticUser();
ParseACL defaultACL = new ParseACL();
// Optionally enable public read access.
defaultACL.setPublicReadAccess(true);
defaultACL.setPublicWriteAccess(true);
ParseACL.setDefaultACL(defaultACL, true);
Log.d(TAG, "Parse ready");
}
public static App getInstance(){
return instance;
}
}
SplashActivity
public class SplashActivity extends AppCompatActivity {
private static final String TAG = "Splash";
private boolean firstTime = true;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Hide title bar
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_splash);
firstTime = getSharedPreferences(Constants.GENERAL_SHARED_PREFS, MODE_PRIVATE)
.getBoolean(Constants.FIRSTTIME, true);
if (isLoggedIn())
if (firstTime)
startActivity(new Intent(SplashActivity.this, FirstTimeActivity.class));
else
startActivity(new Intent(SplashActivity.this, MenuActivity.class));
else {
Log.d(TAG, "Calling Home");
startActivity(new Intent(SplashActivity.this, WelcomeActivity.class));
finish();
}
}
#Override
protected void onResume() {
super.onResume();
}
#Override
protected void onPause() {
super.onPause();
}
#Override
protected void onDestroy() {
super.onDestroy();
}
public boolean isLoggedIn() {
AccessToken accessToken = AccessToken.getCurrentAccessToken();
String parseSession = ParseUser.getCurrentUser().getSessionToken();
return parseSession != null;
}
}
Your stacktrace links to this class in the AOSP.
I think this crash has nothing to do with your app, but as an error in the Launcher class. Try installing from USB debugging and see if that works.
But there are still some details that are blurry. These lines are (from bottom of the stacktrace to the top) the lines that cause problems in com.android.launcher2 package:
https://android.googlesource.com/platform/packages/apps/Launcher2/+/android-4.2.2_r1/src/com/android/launcher2/AppsCustomizePagedView.java#584
https://android.googlesource.com/platform/packages/apps/Launcher2/+/master/src/com/android/launcher2/Launcher.java#2469
https://android.googlesource.com/platform/packages/apps/Launcher2/+/master/src/com/android/launcher2/Launcher.java#2442
From this error, I assume you are using a Nexus or Pixel (or any device with the unaltered source code, meaning stock android.).
From what I can tell from this error, this is not an error related to your app. It appears to be an issue with the launcher you are using. Try installing from USB debugging, or change launcher, and see if that works. Try rebooting your device as well.
Further, from what I see of your code, there are no parcelable classes in use
This error can also be caused when Instant Run loses connection with the Android Emulator as a result of which new app changes are not persisted in the emulator.
Running the app again will solve the issue.
I was trying out the sample programs provided by Sinch and was getting a NullPointerException. I traced the code and found that it was caused by my device not connecting to the SinchService.
The code is as follows
public class LoginActivity extends BaseActivity implements SinchService.StartFailedListener {
private Button mLoginButton;
private EditText mLoginName;
private ProgressDialog mSpinner;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login);
mLoginName = (EditText) findViewById(R.id.loginName);
mLoginButton = (Button) findViewById(R.id.loginButton);
mLoginButton.setEnabled(false);
mLoginButton.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
loginClicked();
}
});
}
#Override
protected void onServiceConnected() {
mLoginButton.setEnabled(true);
getSinchServiceInterface().setStartListener(this);
}
#Override
protected void onPause() {
if (mSpinner != null) {
mSpinner.dismiss();
}
super.onPause();
}
#Override
public void onStartFailed(SinchError error) {
Toast.makeText(this, error.toString(), Toast.LENGTH_LONG).show();
if (mSpinner != null) {
mSpinner.dismiss();
}
}
#Override
public void onStarted() {
openPlaceCallActivity();
}
private void loginClicked() {
String userName = mLoginName.getText().toString();
if (userName.isEmpty()) {
Toast.makeText(this, "Please enter a name", Toast.LENGTH_LONG).show();
return;
}
if (!getSinchServiceInterface().isStarted()) {
getSinchServiceInterface().startClient(userName);
showSpinner();
} else {
openPlaceCallActivity();
}
}
private void openPlaceCallActivity() {
Intent mainActivity = new Intent(this, PlaceCallActivity.class);
startActivity(mainActivity);
}
private void showSpinner() {
mSpinner = new ProgressDialog(this);
mSpinner.setTitle("Logging in");
mSpinner.setMessage("Please wait...");
mSpinner.show();
}
}
I could see that since the service is not connecting I am not getting a correct output when I call getSinchServiceInterface(). It always returns null. My device is connected to the internet and the backend app in the Sinch dashboard seems to be working fine too.
LogCat:
12-22 17:43:38.432 2301-2301/com.login_signup_screendesign_demo E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.login_signup_screendesign_demo, PID: 2301
java.lang.NullPointerException
at calling.LoginActivity.loginClicked(LoginActivity.java:78)
at calling.LoginActivity.access$000(LoginActivity.java:15)
at calling.LoginActivity$1.onClick(LoginActivity.java:32)
at android.view.View.performClick(View.java:4463)
at android.view.View$PerformClick.run(View.java:18770)
at android.os.Handler.handleCallback(Handler.java:808)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5292)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
at dalvik.system.NativeStart.main(Native Method)
What could be the cause of this error and how to solve it?
UPDATE:
I exactly copy pasted the android code downloaded from this page. I am using sinch-rtc-sample-calling app from that file. I compiled and ran the app separately and it was working fine. Then I copy pasted all the java and xml from that app into the one which I am working and it is not working. Why is this happening. This might be the reason for the NullPointerException. After copy pasting I found that the login button is disabled. That means the onServiceConnected() is not executing. I tried calling it manually and that is resulting in the NPE, but that is happening correctly in the standalone app. I am getting these kind of problems only upon integration.
PS : I updated the manifest and gradle as per the new files.
Have had the same issue over the past few days.
In my case it is because I hadn`t added the following in the manifest under application node
<service android:name=".SinchService"/>
Make sure that the setting is in your application manifest. That solved it for me.
everything looks fine, uncomment the commented part because there is one condition which is being checked and it returns
private boolean isStarted() {
return (mSinchClient != null && mSinchClient.isStarted());
}
before getting SinchService and Also check your
private static final String APP_KEY = "app_key";
private static final String APP_SECRET = "app_secret";
private static final String ENVIRONMENT = "sandbox.sinch.com";
in SinchService.java, are the correct or not.
I need to disable headers in BrowseFragment, and add to the ArrayObjectAdapter card. When I do a setHeadersState(HEADERS_DISABLED) application crushes. If I run setHeadersState(HEADERS_DISABLED) method later, for example in onLoadFinished, the application does not crash, but the header bar immediately visible and then hidden, not every time an item is displayed in the adapter.
MainFragment.class
public class MainFragment extends BrowseFragment implements LoaderManager.LoaderCallbacks<List<Module>> {
private static final int MODULES_LOADER_ID = 100;
private ArrayObjectAdapter mRowsAdapter;
#Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
setupUIElements();
setupRowAdapter();
setupListeners();
getLoaderManager().initLoader(MODULES_LOADER_ID, null, this);
}
private void setupUIElements() {
setTitle(getActivity().getString(R.string.app_name));
setBadgeDrawable(getResources().getDrawable(R.drawable.title, getActivity().getTheme()));
setHeadersTransitionOnBackEnabled(false);
setBrandColor(getActivity().getResources().getColor(R.color.fastlane_background));
setHeadersState(HEADERS_DISABLED);
}
private void setupRowAdapter() {
mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
setAdapter(mRowsAdapter);
}
private void setupListeners() {
setOnItemViewSelectedListener(new ItemViewSelectedListener());
setOnItemViewClickedListener(new ItemViewClickedListener());
}
private void loadModules(List<Module> modules) {
ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(new ModulesCardPresenter());
for (Module module : modules) {
listRowAdapter.add(module);
}
HeaderItem header = new HeaderItem(0, "Меню");
mRowsAdapter.add(new ListRow(header, listRowAdapter));
}
#Override
public Loader<List<Module>> onCreateLoader(int id, Bundle args) {
switch (id) {
case MODULES_LOADER_ID:
return new ModulesLoader(getActivity());
default:
return null;
}
}
#Override
public void onLoadFinished(Loader<List<Module>> loader, List<Module> data) {
switch (loader.getId()) {
case MODULES_LOADER_ID:
loadModules(data);
break;
}
}
#Override
public void onLoaderReset(Loader<List<Module>> loader) {
}
static class ModulesLoader extends SimpleAsyncTaskLoader<List<Module>> {
public ModulesLoader(Context context) {
super(context);
}
#Override
public List<Module> loadInBackground() {
Call<Modules> mCall = ServiceHolder.getService()
.getModules(Constants.GET_MODULES_REQUEST);
try {
return mCall.execute().body().getModules();
} catch (Exception e) {
e.printStackTrace();
return Collections.EMPTY_LIST;
}
}
}
private final class ItemViewSelectedListener implements OnItemViewSelectedListener {
#Override
public void onItemSelected(Presenter.ViewHolder itemViewHolder, Object item,
RowPresenter.ViewHolder rowViewHolder, Row row) {
}
}
private final class ItemViewClickedListener implements OnItemViewClickedListener {
#Override
public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item,
RowPresenter.ViewHolder rowViewHolder, Row row) {
}
}
Log:
08-18 16:06:08.331 29647-29647/ E/AndroidRuntime: FATAL EXCEPTION: main
Process: , PID: 29647
**java.lang.RuntimeException: Unable to start activity ComponentInfo{.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.app.Fragment.getView()' on a null object reference**
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
**Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.app.Fragment.getView()' on a null object reference**
at android.support.v17.leanback.app.BrowseFragment.onStart(BrowseFragment.java:1511)
at android.app.Fragment.performStart(Fragment.java:2244)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1002)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1148)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1130)
at android.app.FragmentManagerImpl.dispatchStart(FragmentManager.java:1958)
at android.app.FragmentController.dispatchStart(FragmentController.java:163)
at android.app.Activity.performStart(Activity.java:6274)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) </code>
I have setHeadersState(HEADERS_DISABLED) in my fragment onCreate() method. It looks like you have yours in onActivityCreated(). You should try moving it. Let me know if that works.
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHeadersState(HEADERS_DISABLED)
}
Maybe it'll be useful to you
code.google.com issue
As Viktor Dolgalyov has mentioned, there is a bug filed. #214795 which is followed by #223942 where there is an official reply that this will be fixed around December.
In my application I use a VideoView where playing a MediaPlayer, and in some cases has released me this error:
java.lang.IllegalStateException
at android.media.MediaPlayer.prepareAsync(Native Method)
at android.widget.VideoView.openVideo(VideoView.java:350)
at android.widget.VideoView.setVideoURI(VideoView.java:256)
at android.widget.VideoView.setVideoURI(VideoView.java:239)
at com.wul4.paythunder.hologram.MainActivity.cargarVideo(MainActivity.java:261)
at com.wul4.paythunder.hologram.MainActivity$6.run(MainActivity.java:395)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5466)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
My function to load the video I start it is:
public static void cargarVideo(final String video){
Uri path = Uri.parse(video);
Video.setVideoURI(path);
if(video.contains(NetworkUtils.nombreVideo(prefs.getString("listen",""))) ||
video.contains(NetworkUtils.nombreVideo(prefs.getString("talk","")))) {
Video.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
#Override
public void onPrepared(MediaPlayer mp) {
Log.e("####", "onPrepared");
mp.setLooping(true);
}
});
Video.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
#Override
public void onCompletion(MediaPlayer mediaPlayer) {
Log.e("####", "onCompletion");
cargarVideo(video);
}
});
}
Video.start();
}
This error does not know to be, so if someone knows or has occurred and you can lie down for a hand, he would appreciate it.
A greeting and thanks in advance
EDIT
I searched and read that the solution may lie in the method call setOnPreparedListener including within the function onPrepared the video initialization --> mp.start()
I tried it and now the same behavior seems, do not know if in the future again give the same error
Have you tried to take a look at the Life Cycle of a MediaPlayer Instance?
https://developer.android.com/reference/android/media/MediaPlayer.html
Basically from what I see, you did not properly 'reset' the MediaPlayer object so that it can properly rerun again.
Try having MediaPlayer.reset() and see if it works.
#Override
public void onCompletion(MediaPlayer mediaPlayer) {
Log.e("####", "onCompletion");
// Reset the player here
cargarVideo(video);
}