Sunday, September 11, 2022

How to decide MahaShivaratri date

Maha Shivaratri is an annual Hindu festival commemorating the god Shiva. The name also alludes to the night when Shiva performs the divine dance known as Tandava. 

On the day before the new moon in each month of the luni-solar Hindu calendar, there is a Shivaratri, or "night of Shiva." But once a year, this night is referred to as "Maha Shivaratri" or "the Great Night of Shiva" and occurs in late winter or early spring (February or March). According to the South Indian Hindu calendar, this day is in the month of Magha.

It is a significant Hindu festival, and this festival is solemn and commemorates "overcoming darkness and ignorance" in life and the world. It is observed by remembering Shiva and chanting prayers, fasting, and meditating on ethics and virtues such as honesty, charity, forgiveness, and Shiva's discovery. Dedicated devotees stay awake all night. They call it as "Jagarani", Others go on pilgrimage to Jyotirlingas or to Shiva temples. 

The South Indian calendar observes Maha Shivaratri on Chaturdashi Tithi during Krishna Paksha in the month of Magha, while other parts of India observe it on the 13/14 night of Krishna Paksha in the month of Phalguna of the Hindu calendar, with the Gregorian date remaining the same.

Date: 14th day of māgha māsa (amānta)  Krishna Paksha 
Significance: self study, remembering Shiva, overcoming darkness and ignorance
Observances: Fasting, yoga, jagran all night 
Observed by: Hindus




Saturday, September 3, 2022

How to create your own Android Library and publish it

We'll build and publish our own Android Library in this tutorial. You can use the library in all of your upcoming projects by releasing it. Additionally, other people can utilize the library for their projects.
Therefore, let's begin: 

Creating The Android Library

Open Android Studio and create a new project. Give the name "HttpConnection" to the project.

Click on Finish and your project will be ready.
Now create a new Module in your project

Name Your Library as httpConnectionlib and click finish.


 Your module httpConnection has been added.  Now we need to add code to our library. Create a new Class in the module and name that class. Add the required file to the library.
I have added two classes, FetchData and PutData.

So now, our library is finished, it's time to publish it.

JitPack will be used to publish the library because it makes the procedure great deal simpler. 
GitHub repository is all you require.

Publishing the Android Library
Now we are going to create a new GitHub  public repository and push our code:



Now you can set up your Android Studio to push the code to this repository. You can do it as per my previous blog:  
How to Use Git in Android Studio

Now in your GitHub repository, you should be able to see your code:



Now you need to click on the release button to release this code for usage




Publish the release. Open a new tab and go to jitpack.io.
Insert your repository address and click on Lookup. Your releases will be listed. Now click on Get it.

click on the get it button there and you will get the instructions on how to use it:

Now your Android Library has been published and is ready to be used.
Using the Android Library
Now you can use this android library in any of your projects.
In your project’s build. Gradle add the following line
maven { url ‘https://jitpack.io’ }

And you can add a dependency library here
implementation 'com.GitHub.karjol:httpconnection:0.1.0'


And now you can use the library in your activity.

Example for PutData

private void getSubjectList(String featureSelected, String semSelected) {
if(!featureSelected.equals("") && !semSelected.equals("")) {
progressBar.setVisibility(View.VISIBLE);
Handler handler1 = new Handler();
handler1.post(new Runnable() {
@Override
public void run() {
String[] field = new String[2];
field[0] = "feature";
field[1] = "sem";
String[] data = new String[2];
data[0] = featureSelected;
data[1] = semSelected;
PutData putData = new PutData("https://grcamp.in/qbank/subject.php", "POST", field, data);
if (putData.startPut()) {
if (putData.onComplete()) {
progressBar.setVisibility(View.GONE);
String result = putData.getResult();
if(result.equals("All fields are required")){
Toast.makeText(getApplicationContext(),result,Toast.LENGTH_SHORT).show();

}
else {
try {
JSONArray jsonarry = new JSONArray(result);
//JSONArray subjects = jsonObj.getJSONArray("subname");
for (int i = 0; i < jsonarry.length(); i++) {
JSONObject jsonobject = jsonarry.getJSONObject(i);
list.add(jsonobject.getString("subname"));
}

} catch (JSONException e) {
e.printStackTrace();
}

}

}
}
}
});
}
else {
Toast.makeText(getApplicationContext(),"All fields required", Toast.LENGTH_SHORT).show();
}
}

Example for fetch Data:

buttonFetch.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
progressBar.setVisibility(View.VISIBLE);
//Starting Read data from URL
Handler handler = new Handler();
handler.post(new Runnable() {
@Override
public void run() {
FetchData fetchData = new FetchData("https://grcamp.in/qbank/Fetchstudents.php");
if (fetchData.startFetch()) {
if (fetchData.onComplete()) {
String result = fetchData.getResult();
progressBar.setVisibility(View.GONE);
textView.setText(result);
Log.i("FetchData", result);
}
}
}
});
//End Read data from URL
}
});

If there is any question or confusion regarding this. 
Feel free to ask your questions in the comments below.