Jump to content

How to reload index.html in android app


shure

Recommended Posts

shure

In web client and eletron client. JavaScript code "window.location.reload()" works fine.

But in android app. If I use this function, the app just crash and I need to reopen it.

Thanks for your help

 

Link to comment
Share on other sites

shure
9 hours ago, softworkz said:

Why do you want to do this?

In my plugin page, there is a reload button。“onclick = window.location.reload() ” works fine in web client and eletron client. 

Link to comment
Share on other sites

12 minutes ago, shure said:

In my plugin page, there is a reload button。“onclick = window.location.reload() ” works fine in web client and eletron client. 

What's the purpose of the "reload button"? Reloading destroys all context and should not be needed actually.

Link to comment
Share on other sites

shure
On 6/5/2023 at 3:41 AM, softworkz said:

What's the purpose of the "reload button"? Reloading destroys all context and should not be needed actually.

My plugin let user can add their own javascript code to modify ui for different servers.

but the changement such as a style or link node added will be kept when change server.

Link to comment
Share on other sites

shure

In android app, you can use 

MainActivity.exitApp();
window.open("emby://items", "_blank");

to reload app (if not work, set timeout for window,open less than 200). and

typeof MainActivity === "undefined"

to determine the environment

Link to comment
Share on other sites

15 minutes ago, shure said:

this is the plugin I'm working on https://github.com/Shurelol/Emby.CustomCssJS

Interesting - looks like quite a bit of work you have put into it...

 

17 minutes ago, shure said:

I'm not sure if it violates the policy about emby plugin

I'm not sure either 🙂 

What does the plugin do, what's the purpose..?

Link to comment
Share on other sites

shure
23 minutes ago, softworkz said:

Interesting - looks like quite a bit of work you have put into it...

 

I'm not sure either 🙂 

What does the plugin do, what's the purpose..?

For server managers, they can provide scripts (javascript and css) for their user. 

For users, they can choose to use the scripts provided by  server manager or make their own scripts

 

Link to comment
Share on other sites

shure

For example

As server manager, I provide External Players and Dark Theme.

image.png.15c2b7e329b0cc5d58a18a470d13496b.png

Edited by shure
Link to comment
Share on other sites

shure

As user, I choose to use External Players provided by server manager and my own script Photo Carousel

photo_2023-06-09_09-18-42.jpg.795897a3986be928fa7593b1e7d0c7d1.jpg

Link to comment
Share on other sites

Ahh, so this is some kind of Plug-In system for Emby clients, right?

I understand the Photo Carousel, it's nice.

But why would somebody need all those external players?

Link to comment
Share on other sites

You were asking about Android - how do you interact with the Android app to modify it?

Link to comment
Share on other sites

shure
25 minutes ago, softworkz said:

Ahh, so this is some kind of Plug-In system for Emby clients, right?

I understand the Photo Carousel, it's nice.

But why would somebody need all those external players?

just for more choices, if you use web client in a temporary environment and don‘t want to transcode. you can use local player to play

Link to comment
Share on other sites

shure
26 minutes ago, softworkz said:

You were asking about Android - how do you interact with the Android app to modify it?

the main fuction is completed, there is a bug that if I add a script node in body,  the node will still be there after changing server.

so I need to find a way to reload the index to prevent that you use a script in Server A but  the script still work after you changing to Server B. 

for now, I use 

MainActivity.exitApp();
window.open("emby://items", "_blank");

not stable but work

Link to comment
Share on other sites

3 minutes ago, shure said:

for now, I use 

MainActivity.exitApp();
window.open("emby://items", "_blank");

not stable but work

Where do you use that code? Do you have your own Android app?

Link to comment
Share on other sites

shure
13 minutes ago, softworkz said:
MainActivity.exitApp();

Is Java code, not .js.

For changing assets\www\*`* you either need a rooted Android device or a patching apk - that's what I was wondering about..

MainActivity.exitApp();

did work in JavaScript,

because in jave this function uses Decorator @JavascriptInterface

in apphost.js, you can find 

image.png.dcf3ddb9303589ac776fc896fae21e55.png

Link to comment
Share on other sites

Ah, you're right, MainActivity is exported to js. But how do you change the js files?

Link to comment
Share on other sites

shure

you can also add 

if (webResourceRequest.getUrl().toString().startwith("file:///android_asset/www/index")) {
  return false;
}

in function 

shouldOverrideIrlLoading()

to make 

window.location.reload()

or 

window.location.href = "index.html"

work

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...