Skip to main content

Posts

Showing posts with the label Programming

Work around for Broadcast receiver not working in Chinese mobiles

If you're having trouble with your Android app not responding to certain events in Mi, Oppo, Vivo or Letv devices it's not your fault. This could include and is not limited to, service app not working properly, push notifications not working properly, application not opening up when intended.  It is because of the extensive battery saver and the so-called saving the user from apps spamming their activity. Here's the funniest part about it We wrote to someone very senior at Xiaomi. He reverted that they manually whitelist a few apps, and the rest are by default disallowed from accessing the notifications folder. This was the response. "This usually happens because of whitelisting of apps that can access notifications folder. This is a feature to ensure the user is protected from spam and also helps to ensure RAM/battery usage optimization." We asked what the process was to get an app whitelisted, and did not get a response.    This is coming from a...

How to convert String To DateTime In Unity C#

How to fetch Day, Month or year from date time string? How to get Hour, minute or second from a date time string? Following snippet of code can be used to deal with most of the forms of date time string in Unity C# Instead of having time in the form of   "2020-1-31 12:10:15"  you can also pass "31/1/2020 12:10:15 PM" and or any such case of Date time in string. Then from this DateTime object you can fetch any particular detail like Year shown in example below. System.Globalization.CultureInfo culture = new System.Globalization.CultureInfo("en-US"); DateTime tempDate = Convert.ToDateTime("2020-5-6 12:10:15", culture); Debug.Log("Testing date time conversion: " + tempDate.Year); This could be used to deal with date time strings of the form   "dd:MM:yyyy HH:mm:ss" "yyyy:MM:dd HH:mm:ss"

How to dynamically create object using JSON data from REST API in Unity 3D

Over the years Unity has become all very powerful and not just easy. With it's easy to use interface and handy programming language C# it is one of the best possible IDE out there to make applications and not just games. With the help of SimpleJSON and Unity Networking class you'll see how easy it is to handle web requests in Unity. So today we are going to fetch and display data from REST API request. By displaying data I don't just mean showing the raw output of JSON but making the objects out of the response data which could be further used as per your requirement. Let's get started. First you need to make an API which will return some set of data. For example returning a user's friend list data will contain name, age, joining date of all their friends. For creating an API you may follow my NodeJS tutorial .  Once you have some API let's create a simple Unity application that will make a web request on Button click. Go to a scene in Unity > Right click in ...

How to upload your project to Github

So you're writing all kind of codes now and you want to collaborate with other developers in your team or just simply want to back up your precious code. There are a number of ways to do it. You could simply just a make a zip out of your project and upload it to one of the cloud storage you got. Or you could do use something that is meant for storing codes. One such service is all popular Github. I'll leave the explanation of Github for some other day and get into business right away. What we want to do? We want to upload our project to a repository on Github so that anyone else or just ourselves could download it later on, or sync with our different computers. How? Following steps will guide you through it. Step 1 . First we need a Github account. Go sign up here https://github.com/ and come back for more. Step 2 . We need to setup our computer such that we don't have to provide our username password every time we sync our project. This is done using Secur...

How to make NodeJS MongoDB REST APIs for CRUD operations

We'll use NodeJS Express framework for developing the web-interaction part and Mongoose for saving data to MongoDB. We'll be saving just two details name , and email  of a user. Since I'll be logging in users with their email id only which is validated by Facebook in Facebook Social Login. Install NodeJS and make a folder where your application will run from. This folder is production NodeJS server equivalent on Windows PC. Step 1: Having installed NodeJS now open Command Prompt Window in the folder. Quick Shortcut > Open the folder and click and type 'CMD' or 'cmd' in address bar. Step 2: Initialize the application with a package.json file. Run following command in the command prompt window, $ npm init name: (userdb) version: description: enter description entry point: server.js test command: git repository: keywords: author: Your Name license:  Check details and type 'yes' to proceed. ...

Making Sensor Lights in Unity 3D

Lighting in Unity 3D can some times get tricky. I just spent hours into making sensor lights only to come up with a very obvious solution. At first, I was using baked maps which were the primary reason for my trouble. I know it's kind of obvious but I need to state it for anyone who is struggling with the same. Don't use Baked Lightmaps if you want real-time illumination. As simple as that. I even considered lighting up the environment by real-time switching different lightmaps. Thanks to the complexity of such task I didn't do it. Finally, the solution was to use simple point lights. To give the lights better look I used emissive materials. Here are the results.         Here's how I did it. Created an empty Gameobject Light Controller and under that created two small cuboid, LightsOn and LightsOff and a point light called Bulb here. Added a box collider in Light Controller and ticked Is Trigger .   Here's the script attached to the Light...

Java Programming Basics to Brilliance Part 3

This post is a progression to previous post Java Programming Basics to Brilliance Part 2 . Before we make things complicated lets first get to know what is an array and how we can use it. Quoting from Google, array əˈreɪ/ noun 1 . an impressive display or range of a particular type of thing. "there is a vast array of literature on the topic" verb 1 . display or arrange (things) in a particular way. In Java, an array is an object which holds a specified number of similar number, strings or objects. This depends on the type of array you are making. The size of an array is set when it is initialized. For e.g.  int listOfNumbers[] = {1,2,3,12,2}; This is one way of making an array with values in it. Now recall how everything in Java is nothing but an object. Considering that you can also make a blank array as follows: String my...