Skip to content

Instantly share code, notes, and snippets.

@kashif-umair
Forked from yanguango/AndroidManifest.xml
Last active December 11, 2015 22:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kashif-umair/4672365 to your computer and use it in GitHub Desktop.
Save kashif-umair/4672365 to your computer and use it in GitHub Desktop.
MyApplication mApplication = (MyApplication)getApplicationContext();
String username = mApplication.getUsername();
String password = mApplication.getPassword();
public class MyApplication extends Application {
private static MyApplication singleton;
public MyApplication getInstance(){
return singleton;
}
@Override
public void onCreate() {
super.onCreate();
singleton = this;
}
}
<application android:icon="@drawable/icon" android:label="@string/app_name" android:name="MyApplication">
int[] myArr = new int[3];
Car[] myCars = new Car[3];
myArr[0] = 32;
myArr[1] = 12;
myArr[2] = 50;
myCars[0] = new Car("BMW");
myCars[1] = new Car("VOLVO");
myCars[2] = new Car("FIAT");
String[] myStrings = {"one", "two", "three", "four", "five"};
String[] copiedStrings = new String[4];
// 1 is the start position in the orginal position
// 0 is the start position in the copyTo position
System.arraycopy(myStrings, 1, copiedStrings, 0, 4);
{"two", "three", "four", "five"}
public class MyApplication extends Application {
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
}
@Override
public void onCreate() {
super.onCreate();
}
@Override
public void onLowMemory() {
super.onLowMemory();
}
@Override
public void onTerminate() {
super.onTerminate();
}
}
<!-- content for http://king370.blogspot.com/2013/02/paperclip-rails.html -->
<img alt="Phone_large" src="http://asciicasts.com/system/photos/1/small/phone_large.jpg?1238845838" />
<!-- content for http://king370.blogspot.com/2014/02/chrome-doesnt-allow-decimal-values-in.html -->
<input type="number" />
<input type="number" min="5" />
<input type="number" step="2" />
<input type="number" step="0.3" />
<input type="number" step="any" />
<input type="number" step="any" min="0" />
<!-- content for http://king370.blogspot.com/2013/02/paperclip-rails.html -->
<% form_for @product, :html => { :multipart => true } do |form| %>
<ol class="formList">
<!-- Other fields go here... -->
<li>
<%= form.label :photo, "Photo" %>
<%= form.file_field :photo %>
<li>
<%= form.submit "Submit" %>
</li>
</ol>
<% end %>
<%= image_tag @product.photo.url %>
<%= image_tag @product.photo.url(:small) %>
// content for http://king370.blogspot.com/2013/02/implementing-android-push-notifications.html
UAirship.takeOff(this, options);
PushManager.enablePush();
String apid = PushManager.shared().getAPID();
Logger.info("My Application onCreate - App APID: " + apid);
String action = intent.getAction();
if (action.equals(PushManager.ACTION_PUSH_RECEIVED)) {
//do your code here to handle action
} else if (action.equals(PushManager.ACTION_NOTIFICATION_OPENED)) {
//do your code here to handle action
} else if (action.equals(PushManager.ACTION_REGISTRATION_FINISHED)) {
//do your code here to handle action
}
String apid = intent.getStringExtra(PushManager.EXTRA_APID);
# content for http://king370.blogspot.com/2013/02/implementing-android-push-notifications.html
gcmSender = Your Google API Project Number
transport = gcm
developmentAppKey = App Key obtained from Urbanairship
developmentAppSecret = App Secrete obtained from Urbanairship
# productionAppKey = Your Production App Key
# productionAppSecret = Your Production App Secret
inProduction = false
# content for http://king370.blogspot.com/2013/02/paperclip-rails.html
add_column :products, :photo_file_name, :string
add_column :products, :photo_content_type, :string
add_column :products, :photo_file_size, :integer
add_column :products, :photo_updated_at, :datetime
class Product < ActiveRecord::Base
belongs_to :category
has_attached_file :photo
end
has_attached_file :photo, :styles => { :small => "150x150>" }
has_attached_file :photo, :styles => { :small => "150x150>" },
:url => "/system/:attachment/:id/:style/:basename.:extension",
:path => ":rails_root/public/system/:attachment/:id/:style/:basename.:extension"
has_attached_file :photo, :styles => { :small => "150x150>" },
:url => "/assets/products/:id/:style/:basename.:extension",
:path => ":rails_root/public/assets/products/:id/:style/:basename.:extension"
validates_attachment_presence :photo
validates_attachment_size :photo, :less_than => 5.megabytes
validates_attachment_content_type :photo, :content_type => ['image/jpeg', 'image/png']
# content for http://king370.blogspot.com/2013/02/how-to-prevent-browsers-from-caching.html
before_filter :set_cache_buster
def set_cache_buster
response.headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate"
response.headers["Pragma"] = "no-cache"
response.headers["Expires"] = "Fri, 01 Jan 1990 00:00:00 GMT"
end
# content for http://king370.blogspot.com/2013/02/paperclip-rails.html
script/plugin install git://github.com/thoughtbot/paperclip.git
script/generate paperclip product photo
# OR
rails generate paperclip product photo
<!-- content for http://king370.blogspot.com/2013/02/implementing-android-push-notifications.html -->
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1"
android:versionName="1.0" package="com.urbanairship.push.sample">
<!-- minSdkVersion sets runtime compatibility ("will run on API level 4") -->
<!-- targetSdkVersion should be set to the latest version tested, to disable compatibility modes
("was tested with API level 9 features") -->
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="9"/>
<!-- REQUIRED PERMISSIONS (for Urban Airship GCM) -->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<!-- GCM requires a Google account. -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<!-- Keeps the processor from sleeping when a message is received. -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<!-- This app has permission to register with GCM and receive message -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<!-- MODIFICATION REQUIRED - Replace "com.urbanairship.push.sample" with your package name -->
<permission android:name="com.urbanairship.push.sample.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.urbanairship.push.sample.permission.C2D_MESSAGE" />
<!-- The two elements above ensure that only this application can receive the messages and registration result -->
<!-- END Urban Airship Required Permissions -->
<!-- OPTIONAL Urban Airship Settings -->
<!-- REQUIRED FOR LOCATION -->
<!-- Use ACCESS_COARSE_LOCATION if GPS access is not necessary -->
<!-- uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /-->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- OPTIONAL - This permission is only necessary if your app has multiple processes -->
<!-- <uses-permission android:name="android.permission.BROADCAST_STICKY" /> -->
<!-- END OPTIONAL Urban Airship Settings -->
<application android:label="@string/app_name"
android:icon="@drawable/icon"
android:name="com.urbanairship.push.sample.MyApplication"
android:debuggable="true"
android:allowClearUserData="true"
android:enabled="true">
<activity android:name="com.urbanairship.push.sample.MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.urbanairship.push.sample.PushPreferencesActivity" />
<activity android:name="com.urbanairship.push.sample.LocationActivity" />
<!-- REQUIRED for Urban Airship GCM-->
<receiver android:name="com.urbanairship.CoreReceiver" />
<receiver android:name="com.urbanairship.push.GCMPushReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<!-- MODIFICATION REQUIRED - Use your package name as the category -->
<category android:name="com.urbanairship.push.sample" />
</intent-filter>
</receiver>
<service android:name="com.urbanairship.push.PushService" android:label="Push Notification Service" />
<service android:name="com.urbanairship.push.PushWorkerService" android:label="Push Notification Worker Service" />
<service android:name="com.urbanairship.analytics.EventService" android:label="Event Service" />
<!-- This is required for persisting preferences related to push and location -->
<!-- MODIFICATION REQUIRED - Use your package name + ".urbanairship.provider" in the android:authorities -->
<provider android:name="com.urbanairship.UrbanAirshipProvider"
android:authorities="YOUR_PACKAGE_NAME.urbanairship.provider"
android:exported="false"
android:multiprocess="true" />
<!-- END OF REQUIRED ITEMS -->
<!-- OPTIONAL (for segments support) -->
<service android:name="com.urbanairship.location.LocationService" android:label="Segments Service"/>
<!-- OPTIONAL, if you want to receive push, push opened and registration completed intents -->
<!-- Replace the receiver below with your package and class name -->
<receiver android:name="com.urbanairship.push.sample.IntentReceiver" />
</application>
</manifest>
' WARNING: you should run these statement before sending any HTML to the user.
' if in doubt, use Respose.Buffer = True to buffer all html
Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"
Response.Expires = -1
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Expires" content="Sat, 01 Dec 2001 00:00:00 GMT">
<%
response.setHeader( "Pragma", "no-cache" );
response.setHeader( "Cache-Control", "no-cache" );
response.setDateHeader( "Expires", 0 );
%>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment