Downloading an image from url
If you wish to download an image and display it on your screen in android refer the code below.
The code of the MainActivity is as shown below:
public class MainActivity extends AppCompatActivity {
Button load_img;
ImageView img;
Bitmap bitmap;
ProgressDialog pDialog;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
load_img = (Button)findViewById(R.id.load);
img = (ImageView)findViewById(R.id.img);
load_img.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
new LoadImage().execute(“http://www.meijergardens.org/assets/img/butterfly.png”);
}
});
}
private class LoadImage extends AsyncTask<String, String, Bitmap> {
@Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(MainActivity.this);
pDialog.setMessage(“Loading Image ….”);
pDialog.show();
}
protected Bitmap doInBackground(String… args) {
try {
bitmap = BitmapFactory.decodeStream((InputStream) new URL(args[0]).getContent());
} catch (Exception e) {
e.printStackTrace();
}
return bitmap;
}
protected void onPostExecute(Bitmap image) {
if(image != null){
img.setImageBitmap(image);
pDialog.dismiss();
}else{
pDialog.dismiss();
Toast.makeText(MainActivity.this, “Image Does Not exist or Network Error”, Toast.LENGTH_SHORT).show();
}
}
}
}
Explanation
In our layout we are using a Button and an ImageView. Button is used to trigger the loading process and ImageView is used to display the image.
- In MainActivity we use AsyncTask to load the image from the url.
- In doInBackground we use BitmapFactory class to get the bitmap from the url.
- The onPostExecute is for displaying the bitmap in ImageView.
- The image url should be passed to the AsyncTask.
- When the Load Image Button is pressed the “LoadImage” AsyncTask is executed and Image is displayed in ImageView.
- Finally,we use display ProgressDialog while fetching data.
The output for the above code is as shown:
How to check if your email-id is valid or invalid in android ?
When a user tries to register or login in the app, you have to check if the entered email address is a valid email id or not, that is if it is in the correct format or not. To check for the validation you can make use of the following source codes and steps:
Step 1: In the register activity you can include the statements that are as follows:
EditText emailTxt = (EditText) findViewById(R.id.etEmail);
EditText pwdTxt = (EditText) findViewById(R.id.etPassword);
if (emailTxt.length() == 0) {c
Toast.makeText(RegisterActivity.this, “Email field cannot be empty”, Toast.LENGTH_LONG).show();
}
if (pwdTxt.length() == 0) {
Toast.makeText(RegisterActivity.this, “Password field cannot be empty”, Toast.LENGTH_LONG).show();
}
This code displays a toast message when the email field is empty or when the password field is left empty. The message can be displayed for a short time by using LENGTH_SHORT instead of LENGTH_LONG.
Step 2: The code below uses SharedPreferences which is an interface used for accessing and modifying data to store username and password between activities. For a more complex app you will have to use a database instead.
if (emailTxt.length() != 0 && pwdTxt.length() != 0) {
//check if email is valid
if (isValidEmail(emailTxt.getText())) {
String userNameString = emailTxt.getText().toString();
String pwdString = pwdTxt.getText().toString();
Toast.makeText(RegisterActivity.this, “Registration successful!”, Toast.LENGTH_LONG).show();
SharedPreferences shoppingAdviserPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());// getPreferences(Context.MODE_APPEND);
SharedPreferences.Editor editor = shoppingAdviserPreferences.edit();
editor.putString(“username”, userNameString);
editor.putString(“password”, pwdString);
editor.commit();
finish();
} else {
Toast.makeText(RegisterActivity.this, “Invalid Email”, Toast.LENGTH_LONG).show();
}
}
}
});
}
public final static boolean isValidEmail (CharSequence target) {
if (target == null)
return false;
else {
return Patterns.EMAIL_ADDRESS.matcher(target).matches();
}
}
The EMAIL_ADDRESS format is already been given in android studio. In the above code Patterns.EMAIL_ADDRESS.matcher(target).matches(); is a method in the android library which does the email address validation for us.
The first characters should be the name or the name and any numerical digits the user wants which is followed by the @ symbol followed by the mail servers name followed by a dot which is again followed by the com , org or in etc.
Step 3: After the codes are implemented we can run our app and see how it works. We can enter the email address and press on the register button, which will check the format of the email address. If the fields are empty then it will display a toast message that the fields are empty and if the email address is not in the correct format then it will display the toast message that the email address is invalid. If it’s valid then it displays a toast message saying that the registration is successful.
This is how a isvalidEmail function works.
Step 4: After these codes are being implement the screen will be displayed like the following with the toast messages shown at the end of the screen:
How to create a grid layout with horizontal scroll?
A GridLayout object places components in a grid of cells. Each component takes all the available space within its cell, and each cell is exactly the same size.
The code below will let you build a grid view with horizontal scroll as shown below
<?xml version=”1.0″ encoding=”utf-8″?>
<LinearLayout
xmlns:android=”http://schemas.android.com/apk/res/android”
android:id=”@+id/toast_layout_root”
android:orientation=”horizontal”
android:layout_width=”fill_parent”
android:layout_height=”fill_parent”
android:padding=”8dp”
android:background=”#FFF”>
<HorizontalScrollView xmlns:android=”http://schemas.android.com/apk/res/android”
android:id=”@+id/container_scroll_view”
android:layout_width=”wrap_content”
android:layout_height=”match_parent”
android:background=”#ffffff”>
<GridLayout
xmlns:android=”http://schemas.android.com/apk/res/android”
xmlns:tools=”http://schemas.android.com/tools”
android:id=”@+id/GridLayout1″
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:columnCount=”5″
android:rowCount=”6″
android:orientation=”horizontal”
tools:context=”.GridXMLActivity”>
<RelativeLayout
android:layout_width=”match_parent”
android:layout_height=”match_parent”
>
<View android:layout_marginTop=”20dp”
android:layout_marginLeft=”10dp”
android:layout_marginRight=”5dp”
android:layout_width=”150dp”
android:layout_height=”150dp”
android:paddingLeft=”1dp”
android:paddingRight=”1dp”
android:id=”@+id/View1″
android:layout_row=”0″
android:layout_column=”0″
android:background=”#f5f915″/>
<ImageView
android:layout_marginTop=”10dp”
android:layout_marginLeft=”10dp”
android:layout_marginRight=”5dp”
android:src=”@drawable/sample_1″
android:layout_width=”100dp”
android:layout_height=”100dp”
android:layout_alignTop=”@id/View1″
android:layout_centerInParent=”true”
android:paddingLeft=”1dp”
android:paddingRight=”1dp”
android:id=”@+id/imageView1″
/>
</RelativeLayout>
</GridLayout>
</HorizontalScrollView>
</LinearLayout>
Horizontal scroll view
A HorizontalScrollView is a FrameLayout, meaning you should place one child in it containing the entire contents to scroll; this child may itself be a layout manager with a complex hierarchy of objects. A child that is often used is a LinearLayout in a horizontal orientation, presenting a horizontal array of top-level items that the user can scroll through.
Relative layout
RelativeLayout is a view group that displays child views in relative positions. The position of each view can be specified as relative to sibling elements or in positions relative to the parent RelativeLayout area.
Image View
The ImageView class can load images from various sources, takes care of computing its measurement from the image so that it can be used in any layout manager, and provides various display options such as scaling and tinting.
The code snippet is as shown below:
Your screen will now look like this
For digital marketing services, to increase sales online or offline, 🌐visit: https://aimglobaldigital.com/
Connect with us on:
📸Instagram: https://instagram.com/aimglobalmobi?igshid=o6atyi8pfz74
How to create a register activity in Android?
Step 1: Create a blank activity under your java class. Give the name of the activity as RegisterActivity and check the box of fragments while creating the register activity.
Step 2: In your MainActivity declare the register button and define it by using the following code:
Button registerbutton = (Button) findViewById(R.id.button3);
Here button3 is the id of the register button.
Step 3: in the fragment_register.xml file give the fields that you want in your register screen by using EditText and TextView. This can be done as follows:
<TextView
android:layout_width=“wrap_content”
android:text=“Email”
android:layout_height=“wrap_content” />
<EditText
android:id=“@+id/etEmail”
android:layout_width=“match_parent”
android:layout_marginBottom=“10dp”
android:layout_height=“wrap_content” /> <TextView
android:layout_width=“wrap_content”
android:text=“Password”
android:layout_height=“wrap_content” />
<EditText
android:id=“@+id/etPassword”
android:layout_width=“match_parent”
android:layout_marginBottom=“10dp”
android:layout_height=“wrap_content” />
TextView gives the name of the field that you want to display. And the EditText is where you can enter your data , which here is the email and password.
Like this many other fields can also be added to your register screens.
To add a functionality of registering n clicking the button add the below code in your java file.
registerbutton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
final Intent registerIntent = new Intent().setClass(LandingPageActivity.this, RegisterActivity.class);
startActivity(registerIntent);
}
});
The register button is available on our MainActivity page , which is the landing page here. So when the register button is pressed the setOnClickListener event is called and the register screen appears and you can enter the user’s details there and press the register button at the bottom of the screen to register.
Your screen will look like this:
ShoppingAdviser
ShoppingAdviser is an online site which helps buyers shop online and offline. Here by giving genuine advice and making suggestions to customers – the best deals are offered. Their focus is on clothing and accessories for men, women, kids, etc. that offer personal shopping services.
Online shopping on ‘ShoppingAdviser’ is a form of electronic commerce which allows consumers to directly buy goods or services from a seller over the Internet using a web browser.
How is ShoppingAdviser different from other e-commerce websites?
- It offers online and offline shopping experiences for the customers.
- Customers can get direct access to the products from the sellers.
- Customers can get a detailed description about the product.
- Customers satisfaction is a prime concern.
- Sellers don’t have to worry about the setup of the store thus creating a virtual store.
- If you are one of those shoppers who want touch, see and test the product personally, ShoppingAdviser provides the offline facility to do so.
- Offline facility – it lists out the nearest store near you and you can book a cab or personally visit the store and buy products.
- There is no shipping charges on products and no commission is taken on sale of products – thus products are at a comparatively low price than on any other shopping site!
What is GitHub?
Git allows a team of people to work together, all using the same files. And it also helps the team cope with the confusion that tends to happen when multiple people are editing the same files.
A few Git commands that can be run on command prompt once you install git on your desktop
Configure:
git config –global user.name “Sam Smith”
git config –global user.email sam@example.com
Create a new local repository:
git init
Check out a repository:
git clone /path/to/repository
For a remote server, user:
git clone username@host:/path/to/repository
Add files:
git add
git add *
Commit:
git commit -m “Commit message”
git commit -a
Push:
git push origin master
Status:
git status
Connect to a remote repository:
git remote add origin
git remote -v
Branches:
Create a new branch and switch to it:
git checkout -b
Switch from one branch to another:
git checkout
List all the branches in your repository, and also tell you what branch you’re currently in:
git branch
Delete the feature branch:
git branch -d
Push the branch to your remote repository, so others can use it:
git push origin
Push all branches to your remote repository:
git push –all origin
Pull changes from the repository:
git pull
Delete a branch on your remote repository:
git push origin :
Update from the remote repository
Fetch and merge changes on the remote server to your working directory:
git pull
To merge a different branch into your active branch:
git merge
View all the merge conflicts:
git diff
View the conflicts against the base file:
git diff –base
Preview changes, before merging:
git diff
After you have manually resolved any conflicts, you mark the changed file:
git add
Tags: You can use tagging to mark a significant change set, such as a release:
git tag 1.0.0
CommitId – is the leading characters of the changeset ID, up to 10, but must be unique. Get the ID using:
git log
Push all tags to remote repository:
git push –tags origin
Undo local changes:
git checkout —
Instead, to drop all your local changes and commits, fetch the latest history from the server and point your local master branch at it, do this:
git fetch origin
git reset –hard origin/master
Search:
Search the working directory for foo(): git grep “foo()”
How to enable developer options in your Android phone
One of the most important step in building an application on your mobile,is to make sure that all the settings for running an application is enabled…This can be done by following some simple steps.They are as follows:
- Go to “Settings” in your phone.
- Then go to “About phone”.
- You will find “Build version” in the menu.
- Tap the “Build version” 7 times continuously.
- At the end of the 7th tap a message will pop on your screen saying “you are a developer now”.
- Once you are done with that go back to Settings menu and you will see “Develop options” in the menu.
- Now you can connect a USB to your device from the system.
- Select that and you will find “USB debugging”
- Check that and your connection is enabled!!
Internet Download Manager
Free Internet Download Manager is a powerful and completely free download manager, internet accelerator and file management system. It supports HTTP, FTP, BitTorrent and Flash. It will accelerate download speeds and can resume interrupted transfers. Comes with built in conversion tools and has enhanced audio and video support. Free Internet Download Manager can also schedule downloads and allow you to start and pause transfers at any time.
Internet Download Manager (IDM) is a tool to increase download speeds up to 5 times, resume and schedule downloads. Comprehensive error recovery and resume capability will restart broken or interrupted downloads due to lost connections, network problems, computer shutdowns, or unexpected power outages. Simple graphic user interface makes IDM user friendly and easy to use. Internet Download Manager has a smart download logic accelerator that features intelligent dynamic file segmentation and safe multipart downloading technology to accelerate your downloads.
The software is extremely free and powerful and requires just 10 seconds to install. It will consolidate the internet downloads and uploads and accelerate by up to 600% of the exciting network connection speed with no impact to the system resources. Easily integrates into HTTP/FTP and even BitTorrent as well. Internet users who would like to speed up download and upload times and users who would like to consolidate internet activity into a central area.
Unlike other download managers and accelerators Internet Download Manager segments downloaded files dynamically during download process and reuses available connections without additional connect and login stages to achieve best acceleration performance.
Internet Download Manager supports proxy servers, ftp and http protocols, firewalls, redirects, cookies, authorization, MP3 audio and MPEG video content processing. IDM integrates seamlessly into Microsoft Internet Explorer, Netscape, MSN Explorer, AOL, Opera, Mozilla, Mozilla Firefox, Mozilla Firebird, Avant Browser, MyIE2, and all other popular browsers to automatically handle your downloads. You can also drag and drop files, or use Internet Download Manager from command line. Internet Download Manager can dial your modem at the set time, download the files you want, then hang up or even shut down your computer when it’s done.
Free Social Media Monitoring Tools
Social media monitoring is the act of using a tool to monitor whatever is said on the internet. Social Listening, Online Analytics, Buzz Analysis, Social Media Measurement, Social Media Intelligence, Social Media Management all means the same. Most of the social media monitoring tools crawl all sorts of website including forums, blogs, review sites, news sites, etc. They all crawl the major social networks like Facebook, Twitter, Google+ and YouTube and so on.
The tools allow gaining an insight into the customers, competitors and industry influences. To take full advantage of social media listening, you need to spread your monitoring across several social media channels, and keep a constant watch for new opportunities. Social media monitoring is a great way of turning complaints and negative feedback into positive publicity. It is widely known that no one can control what is being said about a brand in the online environment and it is not possible to please everybody.
Are you looking for Digital Marekting Services : Contact Us
Social Media is an excellent tool to build a community around your product or service, expand your target market and listen to what your customers need. There are various online free social media monitoring tools and we have complied some of them.
1. Hootsuite –
Hootsuite is a web based dashboard that allows monitoring multiple social networks in one place. Collaboration with fellow employees, assign tasks to your team and schedule messages can be done easily. This is one of the great tools to manage multiple accounts like Twitter, LinkedIn, WordPress, Foursquare and Google+ in one platform.
2. TweetReach –
TweetReach is one of the great tools for your business to monitor how your tweet travels. It actually measures the actual impact and implications of social media discussions. It helps in finding out your most influential followers and guides you to target while sharing and promoting the contents online. Hence most of the valuable information can be gained.
3. Klout –
Klout measures influence of topics from across various social media platforms. You can easily track the impact of your links, recommendations and options across social media platforms. Helps you to adjust your posts according to your target audience’s interests and increase you engagement rate.
4. Social Mention –
Social Mention monitors more than one hundred social medial sites. It is one of the best free listening tools on the market as it analyses data in more depth and measures influence with categories like Strength, Sentiment, Passion and Reach.
5. TwentyFeet –
TwentyFeet aggregates your activity in various social media platforms so that one can get the full picture of their online presence. This helps in determining which of your activities are most valuable.
6. Twazzup –
Twazzup is one of the social media for beginners who are looking for a Twitter monitoring tool. All you need to do is to track and you will instantly get real-time updates and also the best keyword related to your search.
7. Addictomatic –
Addictomatic focus on various platforms like Flickr, YouTube, Twitter, WordPress, Bing News, Delicious, Google, etc. It keeps an eye on the recent industry developments and brand reputation.
8. HowSociable –
HowSociable is a handy tool for measuring yours and your competitors’ social media presence. With a free account we can track 12 social sites including Tumblr and WordPress. This enables you to see which platform is best for you and needs further decelopment.
9. Facebook Insights –
The dashboard enables you to receive all the analytics data regarding your facebook page so that you can track growth and impact. With the help of these insights you can understand your followers and reach the right audience.
10. Google Analytics Social Reports –
This tool enables you to visualize your social traffic so that you can know where your time is best spent in the social world.
Top Jobs In Digital Marketing
We are all aware of the changing landscape of the marketing departments. The products and services have changed, strategies and tactics have changed: processes have also changed. Digital marketing centers around the Internet, which has become both a communication vehicle and a very powerful marketing medium as the recent Double-click acquisition by Google demonstrated. The Internet can be used both to push a message to someone like email, IM, RSS, and voice broadcast. Digital marketing can be thought of as the combination of push and pull Internet technologies to execute marketing campaigns.
Digital Marketing is targeted, measurable and interactive marketing of products and services using digital technologies to reach and convert leads into customers and retain them. Objective is to promote brands, build preference and increase sales through various digital marketing techniques. Digital marketing activities are search engine optimization (SEO), search engine marketing (SEM), content automation, campaign marketing, content marketing, influencer marketing, and e-commerce marketing, social media marketing, social media optimization, e-mail direct marketing, display advertising, e–books, optical disks and games, and any other form of digital media. Digital marketing is the use of digital channels to promote or market products and services to consumers and businesses. Some of the top jobs in digital marketing are mentioned below:-
1. Chief Content Officer –
The job of Chief Content Officer is the hottest function in the marketing organization. Most of the leading companies are creating departments around content marketing. Chief Content Officer (CCO) is also known as vice president of content marketing, or director of content marketing strategy. The main function is to maintain the content marketing initiatives on behalf of the company. This is one of the important part of marketing function in both small and large organization.
2. Content strategist –
Content strategist is one who manages the content of the company in an effective way. Content is a business asset and need to be managed efficiently. If content is doubled within the enterprises then it will jump the enterprise in a year.
3. Social Media Manager –
Social Media Manager is the person who is responsible for managing the conversation online. Previously this marketing function was outsourced but now it is a full time job in senior level position with strategic initiatives and fixed goal.
4. Data Scientist –
Data Scientist is the person who has to make significant online presence and find patterns in web analytics and CRM data. They should find questions about the direction of product, marketing and social media trends.
5. Freelancer –
The marketing trend is going on faster these days. The companies are bringing in freelancers for more digital marketing tasks like SEO, PPC management, email management, web design, etc. The freelancers can communicate, analyze and provide more thought leadership for the organization.