Netbeans is one of my favorite IDE, and i use it for coding ionic apps. And here is the plugin that i used in netbeans to write TypeScript Download
Friday, 28 April 2017
Sunday, 23 April 2017
How to get adsense account in a week and start making money online
From my experience its quite easy to get an adsense account. I'm going to mention how i got my adsense account within a week.
1. Created a blog in blogger.com.
2. Changed my blog's theme to be a bit professional, also added navigation menu.
3. Brought professional domain from godaddy.com (i brought .in domain @ just Rs.199).
4. Added 8 posts. I'm a software developer, so I started to write posts about programming. Also added about page for my blog.
5. Finally submitted my blog for adsense.
!!Oh my God on 6th day evening i received my adsense approval email.
1. Created a blog in blogger.com.
2. Changed my blog's theme to be a bit professional, also added navigation menu.
3. Brought professional domain from godaddy.com (i brought .in domain @ just Rs.199).
4. Added 8 posts. I'm a software developer, so I started to write posts about programming. Also added about page for my blog.
5. Finally submitted my blog for adsense.
!!Oh my God on 6th day evening i received my adsense approval email.
Friday, 21 April 2017
Android broadcast event to trigger function when push notification recieved
In your activity add the below code:
@Override
public void onResume() {
super.onResume();
context.registerReceiver(mMessageReceiver, new IntentFilter("any_key"));
}
//Must unregister onPause()
@Override
protected void onPause() {
super.onPause();
context.unregisterReceiver(mMessageReceiver);
}
//this method will handle the broadcast call
private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
//get data from intend
String text = intent.getStringExtra("text");
}
};
Call the below method in any class to trigger the above broadcast event:
static void refreshActivity(Context context, String text) {
Intent intent = new Intent("any_key");
//add any text, if any
intent.putExtra("text", message);
//send to broadcast
context.sendBroadcast(intent);
}
OR you can use Otto library to achive this.
@Override
public void onResume() {
super.onResume();
context.registerReceiver(mMessageReceiver, new IntentFilter("any_key"));
}
//Must unregister onPause()
@Override
protected void onPause() {
super.onPause();
context.unregisterReceiver(mMessageReceiver);
}
//this method will handle the broadcast call
private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
//get data from intend
String text = intent.getStringExtra("text");
}
};
Call the below method in any class to trigger the above broadcast event:
static void refreshActivity(Context context, String text) {
Intent intent = new Intent("any_key");
//add any text, if any
intent.putExtra("text", message);
//send to broadcast
context.sendBroadcast(intent);
}
OR you can use Otto library to achive this.
ionic2 project example
Install NodeJs v6.10.2
Download Project
Open CMD
npm install -g ionic@2.2.3
npm install -g cordova@6.5.0
Download Project
Open CMD
npm install -g ionic@2.2.3
npm install -g cordova@6.5.0
goto project root directory -> cmd -> npm install
ionic serve - to test project in browser
ionic platform add <android/ios> - To add any platform
ionic g page myPage - to generate a new component
ionic g provider myProvider- to generate a new provider
ionic run android --prod -> to run in android (production ready)
ionic build android --prod -> to build apk (production ready)
Wednesday, 19 April 2017
Android WebView sample code
import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class MainActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getSupportActionBar().hide();//to hide action bar
WebView webView = (WebView) findViewById(R.id.webView);
webView.loadUrl("http://mycreativecodes.blogspot.com");
webView.getSettings().setJavaScriptEnabled(true);// enabling javascript
webView.setHorizontalScrollBarEnabled(false);
webView.setWebViewClient(new WebViewClient());
webView.setWebViewClient(new WebViewClient() {// to show progressBar when loading page
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
findViewById(R.id.progress1).setVisibility(View.VISIBLE);
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
findViewById(R.id.progress1).setVisibility(View.GONE);
}
});
}
}
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class MainActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getSupportActionBar().hide();//to hide action bar
WebView webView = (WebView) findViewById(R.id.webView);
webView.loadUrl("http://mycreativecodes.blogspot.com");
webView.getSettings().setJavaScriptEnabled(true);// enabling javascript
webView.setHorizontalScrollBarEnabled(false);
webView.setWebViewClient(new WebViewClient());
webView.setWebViewClient(new WebViewClient() {// to show progressBar when loading page
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
findViewById(R.id.progress1).setVisibility(View.VISIBLE);
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
findViewById(R.id.progress1).setVisibility(View.GONE);
}
});
}
}
Android Hide Action Bar in AppCompactActivity
getSupportActionBar().hide();
//add this inside activity OnCreate methode
Tuesday, 18 April 2017
Android dynamically creating a list using linearlayout
LinearLayout specListLayout = (LinearLayout) findViewById(R.id.specList);//main layout
for(int x=0;x<10;x++){
View child = getLayoutInflater().inflate(R.layout.row, null);
TextView colOne = (TextView) child.findViewById(R.id.colOne);
TextView colTwo = (TextView) child.findViewById(R.id.colTwo);
colOne.setText("Key"+x);
colTwo.setText("Value"+x);
if(x%2==0){
colOne.setBackgroundColor(Color.parseColor("#CCCCCC"));
colTwo.setBackgroundColor(Color.parseColor("#FFFFFF"));
}else{
colOne.setBackgroundColor(Color.parseColor("#FFFFFF"));
colTwo.setBackgroundColor(Color.parseColor("#CCCCCC"));
}
specListLayout.addView(child);
}
row.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:orientation="horizontal"
android:weightSum="10">
<TextView
android:id="@+id/colOne"
android:layout_width="0dp"
android:layout_weight="5"
android:gravity="center_vertical"
android:layout_height="50dp"
android:padding="5dp"
android:text="testing"
android:textColor="@color/black"
android:textStyle="bold" />
<TextView
android:id="@+id/colTwo"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_weight="5"
android:background="#CCCCCC"
android:gravity="center"
android:padding="5dp"
android:text="testing2"
android:textColor="@color/black" />
</LinearLayout>
Subscribe to:
Posts (Atom)