Answer :- Suppose if we use in our activity
Button btnYes;
LinearLayout llMain;
Gallery gallery
ImageButton btnSearch
ImageView backImageView;
@Override
protected void onPause() {
releaseViewMemory(btnYes);
releaseViewMemory(llMain);
releaseViewMemory(gallery);
releaseViewMemory(btnSearch);
releaseImageViewMemory(backImageView);
super.onPause();
}
public static void releaseViewMemory(View view) {
if (view != null) {
Drawable draw = view.getBackground();
if (draw != null) {
draw.setCallback(null);
draw = null;
}
}
}
public static void releaseImageViewMemory(ImageView imgView) {
if (imgView != null) {
Drawable draw = imgView.getBackground();
if (draw != null) {
draw.setCallback(null);
draw = null;
}
draw = imgView.getDrawable();
if (draw != null) {
draw.setCallback(null);
draw = null;
}
}
}
2) Write a method for valid url.
Answer :-
protected void onPause() {
releaseViewMemory(btnYes);
releaseViewMemory(llMain);
releaseViewMemory(gallery);
releaseViewMemory(btnSearch);
releaseImageViewMemory(backImageView);
super.onPause();
}
public static void releaseViewMemory(View view) {
if (view != null) {
Drawable draw = view.getBackground();
if (draw != null) {
draw.setCallback(null);
draw = null;
}
}
}
public static void releaseImageViewMemory(ImageView imgView) {
if (imgView != null) {
Drawable draw = imgView.getBackground();
if (draw != null) {
draw.setCallback(null);
draw = null;
}
draw = imgView.getDrawable();
if (draw != null) {
draw.setCallback(null);
draw = null;
}
}
}
2) Write a method for valid url.
Answer :-
public static boolean isValidURL(String url) {
boolean isValid = false;
String expression = "^(http|https|ftp)\\://[a-zA-Z0-9\\-\\.]+\\.[a-zA-Z]{2,3}(:[a-zA-Z0-9]*)?/?([a-zA-Z0-9\\-\\._\\?\\,\\'/\\\\+&%\\$#\\=~])*$";
CharSequence inputStr = url;
Pattern pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(inputStr);
if (matcher.matches()) {
isValid = true;
}
return isValid;
}
3) Write a method for valid email.
Answer :-
String expression = "^(http|https|ftp)\\://[a-zA-Z0-9\\-\\.]+\\.[a-zA-Z]{2,3}(:[a-zA-Z0-9]*)?/?([a-zA-Z0-9\\-\\._\\?\\,\\'/\\\\+&%\\$#\\=~])*$";
CharSequence inputStr = url;
Pattern pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(inputStr);
if (matcher.matches()) {
isValid = true;
}
return isValid;
}
3) Write a method for valid email.
Answer :-
public static boolean isValidEmail(String email) {
boolean isValid = false;
String expression = "^[\\w\\.-]+@([\\w\\-]+\\.)+[A-Z]{2,4}quot;;
CharSequence inputStr = email;
Pattern pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(inputStr);
if (matcher.matches()) {
isValid = true;
}
return isValid;
}
3) Write a method for valid phone.
Answer :-
public static boolean isValidphone(String phone) {
boolean isValid = false;
String expression = "^[+][0-9]{10,13}$";
CharSequence inputstr = phone;
if (phone.length() == 0)
return false;
Pattern pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(inputstr);
if (matcher.matches()) {
if (phone.length() == 10)
isValid = true;
}
return isValid;
}
boolean isValid = false;
String expression = "^[\\w\\.-]+@([\\w\\-]+\\.)+[A-Z]{2,4}quot;;
CharSequence inputStr = email;
Pattern pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(inputStr);
if (matcher.matches()) {
isValid = true;
}
return isValid;
}
3) Write a method for valid phone.
Answer :-
public static boolean isValidphone(String phone) {
boolean isValid = false;
String expression = "^[+][0-9]{10,13}$";
CharSequence inputstr = phone;
if (phone.length() == 0)
return false;
Pattern pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(inputstr);
if (matcher.matches()) {
if (phone.length() == 10)
isValid = true;
}
return isValid;
}
Hollanda yurtdışı kargo
ReplyDeleteİrlanda yurtdışı kargo
İspanya yurtdışı kargo
İtalya yurtdışı kargo
Letonya yurtdışı kargo
MDYVU
Angila yurtdışı kargo
ReplyDeleteAndora yurtdışı kargo
Arnavutluk yurtdışı kargo
Arjantin yurtdışı kargo
Antigua ve Barbuda yurtdışı kargo
Z8V
Azerbaycan yurtdışı kargo
ReplyDeleteAruba yurtdışı kargo
Avustralya yurtdışı kargo
Azor Adaları yurtdışı kargo
Bahamalar yurtdışı kargo
BZY
شركة تسليك مجاري في عجمان MrZke2YlAw
ReplyDeleteشركة تنظيف سجاد بخميس مشيط ad9aIOVC6c
ReplyDelete