How to get Activities available of Android apps - android

I need to know what the activities available of a given application are in Android.
I know you can do this: List of all activities in App but I was wondering if there is a simpler way an also I DONT WANT TO INSTALL THE APP TO SEE AVAILABLE ACTIVITIES
Let's say I want to open Google PlayStore using startapp plugin: https://github.com/lampaa/org.apache.cordova.startapp to download a specific app, then I need to know what activity to use right ?
navigator.startApp.start([
"com.example.hello", // applucation
"com.example.hello.MainActivity", // activity
"product_id", // key
"100" // value
], function(message) { /* success */
console.log(message); // => OK
},
function(error) { /* error */
console.log('47', error);
});
By the way I'm using Cordova and Sencha Touch (if that matters).
Any help appreciated :)

They are actually listed on AndroidManifest.xml
And there are a couple of apps that can help you getting the file of installed apps.
https://play.google.com/store/apps/details?id=jp.susatthi.ManifestViewer&hl=en

Related

Web Share API navigator.share problem when canceling share dialog IOS and Android

When using MOBILE SHARE (navigator.share), canceling the Share flow causes an unexpected error to appear.
The message can be acknowledged and user is allowed to proceed but this error response is unexpected.
STEPS TO REPLICATE
1.Tap the SHARE icon to initiate the share dialog then:
2.a on iOS, find and tap the close [ x ] control in the upper righthand corner of the dialog to dismiss
2.b on Android, swipe the share overlay down (or whatever way to close/exit this dialog?)
3.The error "AbortError: About due to cancellation of share" appears when:
on iOS, immediately on cancellation
on Android, when attempting to re-engage the Share control.
The error message:
www.example.com says: AbordError: Share canceled
Im using this Vue plugin https://github.com/GabrielBibiano/vue-navigator-share
This is not an issue with Vue.js or any plugin, but something that navigator.share function does.
It is throwing this on canceling/dismissing share action.
Check this example on phone which supports navigator.share.
(NOTE: open this page as desktop site since phones can not run examples)
You can also see this (LOC: 303): https://chromium.googlesource.com/chromium/src/+/34eacf936ac3255925c5045c4385dc9b5f19fa78/chrome/android/javatests/src/org/chromium/chrome/browser/webshare/WebShareTest.java
const share = async () => {
try {
await navigator.share({ url: 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' });
} catch (e) {
if (e.toString().includes('AbortError')) {
alert('Hello world aborted :(');
}
}
}
<button onclick="share()">share (only for phones)</button>

cordova.file.* (all directories) are null

I'm working on Ionic mobile app development.
My requirement is to create client side logger to track issues in app. I used the methods mentioned in https://github.com/pbakondy/filelogger, and I could able to create the log file in both Android and iOS.
For the first time when I open the app, it creates the log file in cordova.file.dataDirectory, when I close and reopen the app in i*OS, I'm trying to read the content of the file which was created using the below
$fileLogger.getLogfile().then(function (loggerContent) {
var temp =loggerContent;
});
But the application says
{
"applicationDirectory":null,
"applicationStorageDirectory":null,
"dataDirectory":null,
"cacheDirectory":null,
"externalApplicationStorageDirectory":null,
"externalDataDirectory":null,
"externalCacheDirectory":null,
"externalRootDirectory":null,
"tempDirectory":null,
"syncedDataDirectory":null,
"documentsDirectory":null,
"sharedDirectory":null
}
So I couldn't able to find the file where i saved my logs.
Please help me resolve this issue or if you could recommend me a different method to get around this issue, that would be great!
Thanks for the answers
There is a check list here and should solve your problem :
1-Be sure that the cordova-file-plugin is installed and works in your test environment.
2-Be sure that the cordova.js file is refrenced by your html and before your code usage.
3-Be sure to call your codes after device_ready state :
check this
4-Call your function after a short delay (use setTimeOut in Javascirpt)
Ali's item 4 is very important:
I had a similiar problem on different platforms: cordova.file.dataDirectory was null.
I tracked cordova.file.dataDirectory over the lifecycle and it was first accessed by my Ionic 2 code BEFORE the device ready event was fired.
My "mistake": I wanted to load data during the constructor(!) of a service. Seems too early.

Stuck solution for my cordovaFile / cordovaFileTransfer trial, still Error

Anybody success to use the plugin cordovaFile & cordovaFileTransfer?
I have failed to understand and failed miserably execution. Case wants to make the upload and download controller. Each tested via the browser, it always appears File / FileTransfer is not defined in Firebug. When I made to console.log as:
console.log($cordovaFile); or
console.log($cordovaFileTransfer); or
console.log($cordovaFileTransfer.download); or
console.log($cordovaFileTransfer.upload);
Its return true, form of the {object}.
But when I call their methods included parameters, for example:
$cordovaFileTransfer.download (urlServer, fileTarget, {}, true);
Direct emerge error: FileTransfer is not defined.
I tried to move the download function to the Service, and then Controller call the function (the umpteenth time search results on google). The result is just the same, the above error.
Because there are user in some forum said should / could only be tested through the device, finally I try to upload ionic.io & I sync via APL ionic view on my Smartphone. But the result is NOTHING.
I tried to improvise a little, try method checkDir / checkFile as follows:
.controller('PhotoCtrl', function($scope, $cordovaFile) {
$scope.downpic = function(){
$cordovaFile.checkDir("/sdcard/storage/emulated/0/").then(function(result){
alert("wow");
}, function(err){
alert("eror");
});
}
})
It turns out alerts that appear "error", I try mutually value directory is as follows:
file///sdcard/storage/emulated/0/
file///storage/emulated/0/
/storage/emulated/0/
Just the same error alerts, the chain problem. My question :
What is the application of ionic cordova can access the internal
storage? (I only have the Mobile Internal Storage, without External
Storage);
I was looking for information about AndroidManifest.xml
uses-permission, the permission is only for external storage. Are
there any other analysis?
Please help, really newbie
Finally, I just got the clear solution from the link below :
https://www.thepolyglotdeveloper.com/2014/09/manage-files-in-android-and-ios-using-ionicframework/

Checking disk space on cordova iOS

I am trying to check disk space available in mobile using below code:
cordova.exec(function(result) {
var diskSizeInMB = result/1024;
alert(diskSizeInMB)
}, function(error) {
alert("Error: " + error);
}, "File", "getFreeDiskSpace", []);
In Android device it gives me correct result, whereas if I use iPhone/iPad it always returns me 0 as a output. Can anyone guide me how to resolve this issue? Or is there a way to check the disk size in iOS using cordova without writing custom plugin? To make this happen I haven't changed any configuration changes
It was a bug, but was fixed long time ago.
Old answer:
I confirm there is a bug on the code, the problem is getFreeDiskSpace is undocumented and cordova team want to remove the native code as getFreeDiskSpace isn't part of the w3c file API.
If you want to fix the bug for you app, go to CDVFile.m and change the line
NSNumber* pNumAvail = [self checkFreeDiskSpace:self.appDocsPath];
to
NSNumber* pNumAvail = [self checkFreeDiskSpace:self.rootDocsPath];
on the getFreeDiskSpace method

Howto use org.chromium.identity for native google connect in Cordova

I would like use native google plus sign feature for connect my phonegap/cordova application (android et IOS).
Usually in Phonegap we use InAppBrowser for include web popup. It's done but suppose the user log with email and password with web UI. So in Android, we used google play for that and the same for IOS.
In january, it's now possible to use Chrome Apps inside Cordova.
http://blog.chromium.org/2014/01/run-chrome-apps-on-mobile-using-apache.html
Many cordova plugins are available and particulary chrome.identity : https://github.com/MobileChromeApps/mobile-chrome-apps/tree/master/chrome-cordova/plugins/chrome.identity
How to use this plugin outside the ChromeApps for native google signIn ?
I'm installed the plugins but none samples to access chrome object and Api.
Thanks for your help
This is an old-ish question but I thought I should post my solution since I hit this tonight... below is how I used the plugin to authenticate and call a service API. Apologies if it's not that efficient, it's been a long night :P (this is built for now on the Cordova starter template)
var app = {
onDeviceReady: function() {
/*********************
* I attached an EventListener to a link so I kept this binding
* Helps when testing to have a link handy to revoke the token
**********************/
app.receivedEvent('deviceready');
/****************************************************************************
* The documentation is a little odd here, but since this isn't
* a Chrome app, we need to set the Manifest JSON manually.
*
* The scopes are to only modify and read a calendar, not sure I need both
* but what the hell...
****************************************************************************/
chrome.runtime.setManifest({
oauth2: {
// ClientID obtained from the Developers Console
client_id: clientID,
scopes: [ 'https://www.googleapis.com/auth/calendar', 'https://www.googleapis.com/auth/calendar.readonly' ]
}
},function(){
// callback for setMainfest, empty..
});
/***********************************************************************
* Because I don't have Google Play Services setup yet I have to use
* the 'interactive' mode which will prompt the user to select the account,
* then show a permission screen.
*
* I have multiple (Google) accounts on my phone so I set the 'accountHint'
* to try to force authenticating my primary account and avoid having to deal
* with a popup.
******************************************************************************/
// Just checking if I already have grabbed it, if so, no need to do it again
if(!bToken){
chrome.identity.getAuthToken(
{
'interactive': true,
'accountHint': ACCOUNT_EMAIL,
},
function(token, acct) {
// set a global variable or debug...
});
}
},
}
var calendar = {
list: function(token) {
// Simple AJAX call, passing the token through and dealing with the results...
// This function just pulls calendar info...
$.ajax({
type: "GET",
url: listURL,
data: encodeURI("access_token="+token),
cache: false,
success:function(result) {
// do something....
}
})
}
}
Hope this helps!

Categories

Resources