How to make a 3D model viewer android app? - android-studio

I'm trying to make my own 3d viewer app.
I just want it works like,
Open an app (tap on my smartphone screen),
Show a 3d model,
Close the app when the back button is tapped.
Actually, I made an app (with Kotlin on android studio) that is working like my idea.
The app is working well with a file that is located on a server.
But I want to make an app that works without an internet connection.
How to import a file(glTF format) to the app.?
In the part,
.appendQueryParameter("file", "PATH/XXXX.gltf")
If the PATH is with "https//", it works with an internet connection.
but, How can I set the PATH local storage in order for the apps to work without internet connections?
Here is the kotlin code snippet that I'm using.
val sceneViewerIntent: Intent = Intent(Intent.ACTION_VIEW)
val intentUri: Uri = Uri.parse("https://arvr.google.com/scene-viewer/1.0").buildUpon()
.appendQueryParameter(
"file","ludovic_v2_gltf.gltf" //<<<<---- how to import this file?
//"https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/Avocado/glTF/Avocado.gltf"
//<<<--- with this line, works very well.
)
.appendQueryParameter("mode", "3d_only")
.build()
sceneViewerIntent.data = intentUri
sceneViewerIntent.setPackage("com.google.ar.core")
startActivity(sceneViewerIntent)
finish()
Thanks a lot!!!
This is my environment.
windows10, android-studio 20212.1Patch1(build on May 18,2022)
My project was started with "empty activity".

Related

How to run multiple apps with the same test case in appium

I need to test two apps in the same test case in Appium ( android )
for example, write test case to publish ads on app (A) and see the ad in the second app (B). Also, Can I run on emulator ? or should apply on real device?
After many research, I found the solution. the simple way to do that by define new driver with the selected app and this cause to close the first app and open new one.
Example Code
return driver
.elementById('username')
.click()
.init(Common.SelectApp(apps.AppName)) //Open new app ( the code below)
.setImplicitWaitTimeout(10000)
.elementById('username')
.click()
// Select App function:
var desired = process.env.npm_package_config_sauce ?
_.clone(require("./helpers/caps").android18) :
_.clone(require("./helpers/caps").android19);
return desired.app = App Name;
This code from appium examples (Node)

How to programmatically open the Bluetooth settings in iOS 10

I'm trying to access the Bluetooth settings through my application using swift.how can access bluetooth setting?
Xcode version - 8.0
swift - 2.3
iOS - 10
func openBluetooth(){
let url = URL(string: "App-Prefs:root=Bluetooth") //for bluetooth setting
let app = UIApplication.shared
app.openURL(url!)
}
Swift 3.0: working up to iOS 10
Note: This URL is "private API". The app will be rejected by App Store reviewers if used.
You will not be able to use the solution by #Siddharth jain. The Problem: The app will be rejected by Apple with a warning that you should never use non-public APIs anymore. Otherwise, you could risk your developer program.
As far as I know, all you can do is open the iPhone settings in general (or get lead to your app settings if there are some. To do so you need the following code
guard let url = URL(string: UIApplication.openSettingsURLString) else {
// Handling errors that should not happen here
return
}
let app = UIApplication.shared
app.open(url)
By this, you will always get a URL you can use without any problems with apple review.
Until now you cannot access to bluetooth settings from your app from iOS 10.
you can see the following link to keep your mind at peace.
https://forums.developer.apple.com/message/146658#146658
Opening the Settings app from another app
Now that iOS 15 seemed to have broken auto-reconnect for known Bluetooth devices (other than audio gadgets), it's extremely annoying. If someone finds a solution, App Store-safe or not, I'm all ears.

ios8 Core Data iCloud Today Widget not synchronizing

I have been unsuccessful in getting core data to work on an app and today widget on my device.
let url = NSFileManager.defaultManager().containerURLForSecurityApplicationGroupIdentifier("group.mygroup.name").URLByAppendingPathComponent("fileName.sqllite")
var error: NSError? = nil
let options = [NSMigratePersistentStoresAutomaticallyOption: true,
NSInferMappingModelAutomaticallyOption: true,NSPersistentStoreUbiquitousContentNameKey:"SharedContainerName"
]
let s = coordinator?.addPersistentStoreWithType(NSSQLiteStoreType, configuration: nil, URL: url, options: options
, error: &error)
I have added a group container that I use for the URL of the stores. I have noticed on the simulators that my persistent coordinator points to the same sqllite file
(URL: file:///Users/xxxx/Library/Developer/CoreSimulator/Devices/6Cxxxxxx/data/Containers/Shared/AppGroup/E65xxxxxx/fileName.sqllite))
This seems to work fine on the simulator and I can store data in my main app and fetch it in today widget. When I run the code on my device the files are at different locations and the databases are not synchronized (no data on the today widget).
My Main App
(URL: file:///private/var/mobile/Containers/Shared/AppGroup/2CCXXX/CoreDataUbiquitySupport/mobile~F74XXX/SharedContainerName/0E8XXXX/store/fileName.sqllite))
Today Widget
(URL: file:///private/var/mobile/Containers/Shared/AppGroup/2CCXXX/CoreDataUbiquitySupport/mobile~F74XXX/SharedContainerName/2FBYYYY/store/fileName.sqllite))
I am assuming this should be fine as they should be synchronized by iCloud. The widget runs fine, however it has no data (like it has not been synchronized). Now debugging this has been tricky as I am unable to get console output while running the today widget. When I run the widget from Xcode as opposed to attaching to the running process (The only way I can get any output on the console) I receive an error core data iCloud: Error: initial sync notification returned an error BRCloudDocsErrorDomain error 12. I receive no notifications. Maybe iCloud and Core Data do not work at this time with a today widget? The core data code in my app and extension are identical so I do not think I have a bug.
According to this Apple Developer Forum message from an Apple employee:
None of iCloud is accessible from within an Extension in iOS 8.0
and he adds in another message:
Document syncing, I should clarify, or anything which requires file coordination. I'm not sure about KVS or CloudKit
The recommendation is to expose the application state to extensions using some other method (plist, separate files, etc), which is a bit of a bummer.

.wav sound file stored on server does NOT play when Loaded in web application

this is the scenario i'm trying to achieve: a sound stored on the same server as a web application, plays when a condition is met on the client. It works perfectly when I run it in the IDE and change the webconfig to point to the server where the DB is. However when I deploy it and access it via the browser, the sound does not play. The same sound that played when i used my development machine. Code is:
var configsetings = new System.Configuration.AppSettingsReader();
string soundPath= configsetings.GetValue("Notification",typeof(System.String)).ToString();
var sound = new System.Media.SoundPlayer { SoundLocation = Server.MapPath(soundPath) };
sound.Load();
sound.Play();
web config is:
<add key="Notification" value="~/beep-4.wav" />
The sound file is sitting in the root folder of the ASP.NET web application. So what could be wrong? There is no audio output device on the server neither is there a player like media player nevertheless these factors did NOT stop it from working in my dev machine.
Looking at the code you posted I will assume you wrote it in C#.
So, this code will run on the server-side, and the client-side (the web browser) will never know about it or about your audio file. Please read about asp.net code-behind and how it works. If you want to play an audio file in the browser (client-side), you need to use either javascript, or flash, or the < audio > tag from html5.
By installing a sound card on a server you will only achieve (in a best case scenario) to get the file played on that server.
Thanks yms, the tag worked. I put a routine that writes the tag's HTML to a div at run time and put it in a timer.
sounddiv.InnerHtml = "<audio preload=\"auto\" autoplay=\"autoplay\">" +
"<source src=\"" + soundPath + "\" type=\"audio/wav\" />" +
" Your browser does not support the audio tag. </audio>";
This code is called in the code behind in a timer in response to the condition.
So the sound repeats every 30 seconds. Problem solved. Thanks guys for the leads.

Is there a way to refresh your phonegap application - eg, build the page and start running the scripts from the beginning?

Is there any way to do this?
E.g., if a user starts the app with no internet connection, no remote scripts can be loaded, and the application basically can't run and I display a "No internet" page. But if the user gets internet later and the application is still running, is there any way to just "restart" ?
how about -
document.location = "index.html"
PhoneGap applications are just like an embedded website - you should be able to go to any hyperlink you wish (mind the whitelists).
Of course, if you also want to detect when it's again online, you should use the PhoneGap Network API to bind to those online/offline events.
In general thought, have you ever thought of using the HTML5 manifest functionality to actually let your local PhoneGap app cache those remote scripts? That way your app could still run, even when offline (except if it needs remote data to "do your thing")...
Hope this helps!
Try this
navigator.app.loadUrl("file:///android_asset/www/index.html", {wait:2000, loadingDialog:"Wait,Loading App", loadUrlTimeoutValue: 60000});
Accepted solution works, but might fail if you have an SPA with html5 url routing.
Here's a safest solution:
// keep startup url (in case your app is an SPA with html5 url routing)
var initialHref = window.location.href;
function restartApplication() {
// Show splash screen (useful if your app takes time to load)
navigator.splashscreen.show();
// Reload original app url (ie your index.html file)
window.location = initialHref;
}

Resources