Titanium create calendar event - android

I am trying to create calendar event in my Titanium App for Android Platform. For that I am using below code, It does't give any error also didn't to create any calendar events
var calendars = Ti.Android.Calendar.selectableCalendars;
var names =[];
for (var i = 0; i<calendars.length; i++) {
names.push(calendars[i].name);
}
var calendarDialog = Titanium.UI.createOptionDialog({
title: 'Select a Calendar',
options: names,
cancel:1
});
calendarDialog.addEventListener('click', function(e){
var ci = e.index+1;
var calendar = Ti.Android.Calendar.getCalendarById(ci);
var eventBegins = new Date(2011, 12, 26, 12, 0, 0);
var eventEnds = new Date(2011, 12, 26, 14, 0, 0);
var hasReminder = true;
var details = {
title: 'i m testing',
description: 'message',
begin: eventBegins,
end: eventEnds,
hasAlarm:true,
allDay:true
};
var event = calendar.createEvent(details);
if (hasReminder)
{
var reminderDetails = {
minutes: 10,
method: Ti.Android.Calendar.METHOD_ALERT
};
event.createReminder(reminderDetails);
}
alert('Event was created!');
});
calendarDialog.show();
Anyone help me to solve this issue.. My Titanium SDK version is 1.7.5, I have tried this in Android 2.3 Phone

The following link might help you.
https://github.com/codememan/Titanium-Calendar
you need to add the necessary file in your project then you can import and run the Code from the .js file.

Related

How to download and get offline tiles in ionic 3 android app?

I am trying to develop a hybrid ol3 map application using ionic3 with angularjs. I have generated xyz tiles of the map service which I was able to use for online maps. When I tried using them for download to a local directory of mobile and use them I am facing issues. Kindly provide any help which is much appreciated. I I could not trace any errors. Kindly suggest me how to check if any errors to test the maps.
//For downloading the image from server and stores it into mobile directory.
this.file.createDir(this.file.externalRootDirectory, 'Offline/Maps/custom_', true).then((files) => {
this.file.createDir(this.file.externalRootDirectory, 'Offline/Maps/custom_/02_02', true).then((files) => {
}).catch((err) => {
});
}).catch((err) => {
});
const imageURL = 'https://server.com/documents/ionic/path_track/maps/0041_0041.jpeg';
const fileTransfer: FileTransferObject = this.transfer.create();
const imageName = imageURL.split('/').pop();
//alert(imageName+"#"+this.file.externalRootDirectory);
//alert(imageName);
fileTransfer.download(imageURL, this.file.externalRootDirectory+'Offline/Maps/custom_07/02_02/'+imageName).then((entry) => {
//loader.dismiss();
//this.showOfflineButton = true;
}, (error) => {
let alert = this.alertCtrl.create({
message: 'Map is not downloaded '+JSON.stringify(error),
buttons: ['Ok'],
enableBackdropDismiss: false,
cssClass:'alert-error'
});
alert.present();
});
//For retrieving image from the mobile directory and to display into mobile app.
var config = {
"bounds": {
"left" : 68.1060582899974,
"bottom" : 6.72246026992798,
"right" : 97.7525939941406,
"top" : 37.0967391635301
}
};
var bounds = [config.bounds.left, config.bounds.bottom, config.bounds.right, config.bounds.top];
var resolutions = [
0.1186495269281333,
0.0593247634640666,
0.0296623817320333,
0.0148311908660167,
0.0074155954330083,
0.0037077977165042,
0.0018538988582521,
0.000926949429126,
0.000463474714563,
0.0002317373572815,
0.0001158686786408,
0.0000579343393204,
0.0000289671696602,
0.0000144835848301,
0.000007241792415
];
var projection_epsg_no = 4326
var layername = 'seamless_xyz1';
var tileGrid = new ol.tilegrid.TileGrid({
extent: bounds,
resolutions: resolutions,
origin: ol.extent.getTopLeft(bounds),
projection: 'EPSG:4326',
tileSize: [256, 256]
});
var view = new ol.View({
extent: [55.948355423604156, 4.853611184459009, 101.73937104860416, 38.07626743445901],
zoom: 10,
center: [78.48695, 17.41217],
projection: 'EPSG:4326',
resolutions: resolutions
});
var tms_source = new ol.source.XYZ({
projection: 'EPSG:4326',
tileGrid: tileGrid,
url: this.file.externalRootDirectory+'/Offline/Maps/custom_{z}/{x}/{-y}.jpeg'
//url: this.file.externalRootDirectory+'/Offline/Maps/custom_07/02_02/0041_0043.jpeg' (If I am giving static image name then its coming fine but not able to do it dynamically.)
});
var basegroup = new ol.layer.Tile({
source: tms_source,
extent: bounds
});
var mapview;
if(this.Source_lat == undefined || this.Source_long == undefined){
this.current_location1 = 'Location is not available.';
mapview = new ol.View({
projection: 'EPSG:4326',
center: [82.491,21.899],
extent: [66.2329, 7.68083, 98.2223, 39.03874],
maxZoom:16,
minZoom: 8,
zoom: 8
});
}else{
this.current_location1 = this.Source_lat+', '+this.Source_long;
mapview = new ol.View({
projection: 'EPSG:4326',
center: [this.Source_long,this.Source_lat],
extent: [66.2329, 7.68083, 98.2223, 39.03874],
maxZoom:10,
minZoom: 10,
zoom: 10
});
}
map = new ol.Map({
target: 'offline_map',
controls: ol.control.defaults({
zoom: false,
attribution: false,
rotate: false
}),
layers: [basegroup, jsonLayer_net1, jsonLayer_net],
overlays: [jsonoverlay],
view: mapview
});
Thanks in advance

Ionic get installed apps on android device with icon

I know this question is already asked but I have problem in that solution which is not answered there.
I used this plugin but this gives me error:
var success = function (app_list) { alert(JSON.stringify(app_list)); };
var error = function (app_list) { alert("Oopsie! " + app_list); };
Applist.createEvent('', '', '', '', '', success, error)
How can I remove this error? I downloaded it running:
npm i cordova-plugin-applist
Error message:
Cannot find name 'Applist'
Add
import * as Applist from 'cordova-plugin-applist2/www/Applist.js';
import { Platform } from '#ionic/angular';
to your component .ts file
Then to use it in probably constructor
constructor(public platform: Platform) {
platform.ready().then(
function(){
if(platform.is('android') && !platform.is('mobileweb')){
var success = function(app_list) {
//success function
console.log(app_list);
};
var error = function(app_list) {
//error
console.log("An Error occured while fetching App Lists");
console.error(app_list);
};
//for the date parameters, any date is okay,
//the first date should be in the past
Applist.createEvent('', '', '', new Date(1999, 10, 11, 12, 12, 12, 12), new Date(), success, error);
}
}
);
}

Connecting Unity with SQL server

He everyone I have problem with connect to sql server in android type phone i will summit code that code is working in windows application but when i build to android its give error I need and hope to help me for solve this issue thank u
This is Error when I build to android apk:
and this is code the which is working in windowns app:
#pragma strict
import System;
import System.Data;
import System.Data.SqlClient;
var dbcon : IDbConnection;
var connectionString : String;
function Start () {
connectionString = "Server=dbdatabase.mssql.somee.com; Database=dbdatabase;User ID=dbdatabase_SQLLogin_1; Password=1j8uc1yyja";
}
function Update () {
}
var user :String="";
var pas :String="";
function OnGUI()
{
GUI.Label(new Rect(150, 130, 100, 100), "Name :");
GUI.Label(new Rect(150, 160, 120, 120), "Pass :");
user = GUI.TextField(new Rect(200, 130, 100, 20), user);
pas=GUI.TextField(new Rect(200,160,100,20),pas);
if (GUI.Button(Rect(200,190,100,50),"Login"))
{
dbcon = new SqlConnection(connectionString);
dbcon.Open();
var dbcmd : IDbCommand = dbcon.CreateCommand();
var cmdSql : String = "SELECT name FROM setting WHERE name='"+user+"' and pass='"+pas+"'";
dbcmd.CommandText = cmdSql;
var reader : IDataReader = dbcmd.ExecuteReader();
while(reader .Read()) {
var nm : String = reader ["name"].ToString();
print ("OK "+nm);
}
reader .Close();
reader = null;
dbcon.Close();
dbcon = null;
}
}

Chart.js + Intel XDK

I'm triyng to add a chart to my Android app using Chart.js
At Intel-XDK emulator this works perfectly, but if I try run it using App Preview or if I build the apk I can't see the chart.
function Skills(){
document.getElementById("MinhasHabilidades").style.display = 'block';
document.getElementById("inicio").style.display = 'none';
var ChartData = {
labels: ["Ler", "Ouvir", "Escrever", "Falar"],
datasets: [{
fillColor: "rgba(0,128,255,0.5)",
strokeColor: "rgba(220,220,220,0.8)",
highlightFill: "rgba(220,220,220,0.75)",
highlightStroke: "rgba(220,220,220,1)",
data: [9, 13, 4, 12]
}]
};
var ctx = document.getElementById("myChart").getContext("2d");
window.myBar = new Chart(ctx).Radar(ChartData, {responsive: true});
}
When I call the "new Chart(ctx)..." the function stop.

How to export multiple modules from single JS file in Cordova/PhoneGap Plugin?

I am developing a custom Cordova plugin. For some reason, I am restricted to expose all my JS objects through single JavaScript file only. Below sample JS replicating my Problem
My JS have 2 objects apple and orange, I have to export them from single file
var apple = function() {
type: "macintosh",
color: "red",
getInfo: function () {
return this.color + ' ' + this.type + ' apple';
};
var orange = function() {
color: "red2",
show: function () {
alert("test type 2 also passed dude !----");;
}
};
I am exporting them like this
var apple1 = new apple();
module.exports = apple1;
var orange1 = new orange();
module.exports = orange1;
My problem is orange1 is overriding apple1 export. How to export both apple1 and orange1 using module.exports? or there any other way?
Please provide me some inputs. Any samples are most welcome.
Following approach worked for me.
var apple1 = new apple();
var orange1 = new orange();
var myExports = module.exports;
myExports .apple1 = apple1;
myExports .orange1 = orange1;

Categories

Resources